ZQuest Classic Coverage Report


Directory: src/
File: src/qst.cpp
Date: 2024-08-15 07:17:26
Exec Total Coverage
Lines: 8947 12532 71.4%
Functions: 98 130 75.4%
Branches: 6297 10711 58.8%

Line Branch Exec Source
1 #include "allegro/file.h"
2 #include "base/flags.h"
3 #include "base/util.h"
4 #include "base/version.h"
5 #include "base/zapp.h"
6 #include "base/qrs.h"
7 #include "base/cpool.h"
8 #include "base/autocombo.h"
9 #include "base/packfile.h"
10 #include "base/dmap.h"
11 #include "base/combo.h"
12 #include "base/msgstr.h"
13 #include "base/flags.h"
14 #include <filesystem>
15 #include <memory>
16 #include <optional>
17 #include <stdio.h>
18 #include <cstring>
19 #include <string>
20 #include <map>
21 #include <vector>
22 #include <assert.h>
23 #include <fmt/format.h>
24
25
26 #include "metadata/sigs/devsig.h.sig"
27 #include "metadata/sigs/compilersig.h.sig"
28 #include "metadata/versionsig.h"
29 #include "base/zc_alleg.h"
30 #include "base/zdefs.h"
31 #include "base/colors.h"
32 #include "tiles.h"
33 #include "base/zsys.h"
34 #include "qst.h"
35 #include "defdata.h"
36 #include "subscr.h"
37 #include "zc/replay.h"
38 #include "zc/zasm_utils.h"
39 #include "zc/zc_custom.h"
40 #include "sfx.h"
41 #include "md5.h"
42 #include "zinfo.h"
43 #include "zc/ffscript.h"
44 #include "particles.h"
45 #include "dialog/alert.h"
46 #include "base/misctypes.h"
47 #include "base/initdata.h"
48
49 extern FFScript FFCore;
50 extern ZModule zcm;
51 extern zcmodule moduledata;
52 extern uint8_t __isZQuest;
53 extern sprite_list guys, items, Ewpns, Lwpns, chainlinks, decorations;
54 extern particle_list particles;
55 extern void setZScriptVersion(int32_t s_version);
56
57 static bool read_ext_zinfo = false, read_zinfo = false;
58 static bool loadquest_report = false;
59 static char const* loading_qst_name = NULL;
60 static byte loading_qst_num = 0;
61 static byte subscr_mode = ssdtMAX;
62 dword loading_tileset_flags = 0;
63
64 int32_t First[MAX_COMBO_COLS]={0},combo_alistpos[MAX_COMBO_COLS]={0},combo_pool_listpos[MAX_COMBO_COLS]={0},combo_auto_listpos[MAX_COMBO_COLS]={0};
65 map_and_screen map_page[MAX_MAPPAGE_BTNS]= {{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0},{0,0}};
66
67 #ifdef _MSC_VER
68 #define strncasecmp _strnicmp
69 #endif
70
71 #ifndef _AL_MALLOC
72 #define _AL_MALLOC(a) _al_malloc(a)
73 #define _AL_FREE(a) _al_free(a)
74 #endif
75
76 using std::string;
77 using std::pair;
78
79 extern int32_t hero_animation_speed; //lower is faster animation
80 extern byte *colordata;
81 extern tiledata *newtilebuf;
82 extern byte *trashbuf;
83 extern itemdata *itemsbuf;
84 extern wpndata *wpnsbuf;
85 extern comboclass *combo_class_buf;
86 extern guydata *guysbuf;
87 extern ZCHEATS zcheats;
88 extern char palnames[MAXLEVELS][17];
89 extern char *byte_conversion(int32_t number, int32_t format);
90 extern char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2);
91 string zScript;
92 365 std::map<int32_t, script_slot_data > ffcmap;
93 365 std::map<int32_t, script_slot_data > globalmap;
94 365 std::map<int32_t, script_slot_data > genericmap;
95 365 std::map<int32_t, script_slot_data > itemmap;
96 365 std::map<int32_t, script_slot_data > npcmap;
97 365 std::map<int32_t, script_slot_data > ewpnmap;
98 365 std::map<int32_t, script_slot_data > lwpnmap;
99 365 std::map<int32_t, script_slot_data > playermap;
100 365 std::map<int32_t, script_slot_data > dmapmap;
101 365 std::map<int32_t, script_slot_data > screenmap;
102 365 std::map<int32_t, script_slot_data > itemspritemap;
103 365 std::map<int32_t, script_slot_data > comboscriptmap;
104 365 std::map<int32_t, script_slot_data > subscreenmap;
105 void free_newtilebuf();
106 bool combosread=false;
107 bool mapsread=false;
108 bool fixffcs=false;
109 bool fixpolsvoice=false;
110
111 15038 void script_slot_data::update()
112 {
113
2/5
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✓ Branch 4 taken 15034 times.
15038 switch (format)
114 {
115 case SCRIPT_FORMAT_INVALID:
116 4 output = fmt::format("{} --{}", slotname, scriptname);
117 4 break;
118 case SCRIPT_FORMAT_DISASSEMBLED:
119 output = fmt::format("{} ++{}", slotname, scriptname);
120 break;
121 case SCRIPT_FORMAT_ZASM:
122 output = fmt::format("{} =={}", slotname, scriptname);
123 break;
124 15034 case SCRIPT_FORMAT_DEFAULT:
125 default:
126 15034 output = fmt::format("{} {}", slotname, scriptname);
127 15034 }
128 15038 }
129
130 char qstdat_string[2048] = { 0 };
131
132 static zinfo* load_tmp_zi = NULL;
133
134 int32_t memDBGwatch[8]= {0,0,0,0,0,0,0,0}; //So I can monitor memory crap
135 const byte clavio[9]={97,109,111,110,103,117,115,0};
136
137 //enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
138 // qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
139
140 const char *qst_error[] =
141 {
142 "OK","File not found","Invalid quest file",
143 "Version not supported","Obsolete version",
144 "Missing new data" , /* but let it pass in ZQuest */
145 "Internal error occurred", "Invalid password",
146 "Quest title doesn't match saved game", "Save file is for older version of quest; please start new save",
147 "Out of memory", "File Debug Mode", "Canceled", "", "No quest assigned"
148 };
149
150 //for legacy quests -DD
151 enum { ssiBOMB, ssiSWORD, ssiSHIELD, ssiCANDLE, ssiLETTER, ssiPOTION, ssiLETTERPOTION, ssiBOW, ssiARROW, ssiBOWANDARROW, ssiBAIT, ssiRING, ssiBRACELET, ssiMAP,
152 ssiCOMPASS, ssiBOSSKEY, ssiMAGICKEY, ssiBRANG, ssiWAND, ssiRAFT, ssiLADDER, ssiWHISTLE, ssiBOOK, ssiWALLET, ssiSBOMB, ssiHCPIECE, ssiAMULET, ssiFLIPPERS,
153 ssiHOOKSHOT, ssiLENS, ssiHAMMER, ssiBOOTS, ssiDIVINEFIRE, ssiDIVINEESCAPE, ssiDIVINEPROTECTION, ssiQUIVER, ssiBOMBBAG, ssiCBYRNA, ssiROCS, ssiHOVERBOOTS,
154 ssiSPINSCROLL, ssiCROSSSCROLL, ssiQUAKESCROLL, ssiWHISPRING, ssiCHARGERING, ssiPERILSCROLL, ssiWEALTHMEDAL, ssiHEARTRING, ssiMAGICRING, ssiSPINSCROLL2,
155 ssiQUAKESCROLL2, ssiAGONY, ssiSTOMPBOOTS, ssiWHIMSICALRING, ssiPERILRING, ssiMAX
156 };
157
158 static byte deprecated_rules[QUESTRULES_NEW_SIZE];
159
160
161 char *byte_conversion(int32_t number, int32_t format)
162 {
163 static char num_str[40];
164
165 if(format==-1) //auto
166 {
167 format=1; //bytes
168
169 if(number>1024)
170 {
171 format=2; //kilobytes
172 }
173
174 if(number>1024*1024)
175 {
176 format=3; //megabytes
177 }
178
179 if(number>1024*1024*1024)
180 {
181 format=4; //gigabytes (dude, what are you doing?)
182 }
183 }
184
185 switch(format)
186 {
187 case 1: //bytes
188 sprintf(num_str,"%db",number);
189 break;
190
191 case 2: //kilobytes
192 sprintf(num_str,"%.2fk",float(number)/1024);
193 break;
194
195 case 3: //megabytes
196 sprintf(num_str,"%.2fM",float(number)/(1024*1024));
197 break;
198
199 case 4: //gigabytes
200 sprintf(num_str,"%.2fG",float(number)/(1024*1024*1024));
201 break;
202
203 default:
204 abort();
205 break;
206 }
207
208 return num_str;
209 }
210
211 char *byte_conversion2(int32_t number1, int32_t number2, int32_t format1, int32_t format2)
212 {
213 static char num_str1[40];
214 static char num_str2[40];
215 static char num_str[80];
216
217 if(format1==-1) //auto
218 {
219 format1=1; //bytes
220
221 if(number1>1024)
222 {
223 format1=2; //kilobytes
224 }
225
226 if(number1>1024*1024)
227 {
228 format1=3; //megabytes
229 }
230
231 if(number1>1024*1024*1024)
232 {
233 format1=4; //gigabytes (dude, what are you doing?)
234 }
235 }
236
237 if(format2==-1) //auto
238 {
239 format2=1; //bytes
240
241 if(number2>1024)
242 {
243 format2=2; //kilobytes
244 }
245
246 if(number2>1024*1024)
247 {
248 format2=3; //megabytes
249 }
250
251 if(number2>1024*1024*1024)
252 {
253 format2=4; //gigabytes (dude, what are you doing?)
254 }
255 }
256
257 switch(format1)
258 {
259 case 1: //bytes
260 sprintf(num_str1,"%db",number1);
261 break;
262
263 case 2: //kilobytes
264 sprintf(num_str1,"%.2fk",float(number1)/1024);
265 break;
266
267 case 3: //megabytes
268 sprintf(num_str1,"%.2fM",float(number1)/(1024*1024));
269 break;
270
271 case 4: //gigabytes
272 sprintf(num_str1,"%.2fG",float(number1)/(1024*1024*1024));
273 break;
274
275 default:
276 abort();
277 break;
278 }
279
280 switch(format2)
281 {
282 case 1: //bytes
283 sprintf(num_str2,"%db",number2);
284 break;
285
286 case 2: //kilobytes
287 sprintf(num_str2,"%.2fk",float(number2)/1024);
288 break;
289
290 case 3: //megabytes
291 sprintf(num_str2,"%.2fM",float(number2)/(1024*1024));
292 break;
293
294 case 4: //gigabytes
295 sprintf(num_str2,"%.2fG",float(number2)/(1024*1024*1024));
296 break;
297
298 default:
299 abort();
300 break;
301 }
302
303 sprintf(num_str, "%s/%s", num_str1, num_str2);
304 return num_str;
305 }
306
307 char *ordinal(int32_t num)
308 {
309 static const char *ending[4] = {"st","nd","rd","th"};
310 static char ord_str[8];
311
312 char *end;
313 int32_t t=(num%100)/10;
314 int32_t n=num%10;
315
316 if(n>=1 && n<4 && t!=1)
317 end = (char *)ending[n-1];
318 else
319 end = (char *)ending[3];
320
321 sprintf(ord_str,"%d%s",num%10000,end);
322 return ord_str;
323 }
324
325 int32_t get_version_and_build(PACKFILE *f, word *version, word *build)
326 {
327 int32_t ret;
328 *version=0;
329 *build=0;
330 byte temp_map_count=map_count;
331 byte temp_midi_flags[MIDIFLAGS_SIZE];
332 memcpy(temp_midi_flags, midi_flags, MIDIFLAGS_SIZE);
333
334 zquestheader tempheader;
335
336 if(!f)
337 {
338 return qe_invalid;
339 }
340
341 ret=readheader(f, &tempheader);
342
343 if(ret)
344 {
345 return ret;
346 }
347
348 map_count=temp_map_count;
349 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
350 *version=tempheader.zelda_version;
351 *build=tempheader.build;
352 return 0;
353 }
354
355
356 bool find_section(PACKFILE *f, int32_t section_id_requested)
357 {
358
359 if(!f)
360 {
361 return false;
362 }
363
364 int32_t section_id_read;
365 bool catchup=false;
366 word dummy;
367 byte tempbyte;
368 char tempbuf[65536];
369
370
371 switch(section_id_requested)
372 {
373 case ID_RULES:
374 case ID_STRINGS:
375 case ID_MISC:
376 case ID_TILES:
377 case ID_COMBOS:
378 case ID_CSETS:
379 case ID_MAPS:
380 case ID_DMAPS:
381 case ID_DOORS:
382 case ID_ITEMS:
383 case ID_WEAPONS:
384 case ID_COLORS:
385 case ID_ICONS:
386 case ID_INITDATA:
387 case ID_GUYS:
388 case ID_MIDIS:
389 case ID_CHEATS:
390 break;
391
392 default:
393 al_trace("Bad section requested!\n");
394 return false;
395 break;
396 }
397
398 dword section_size;
399
400 //section id
401 if(!p_mgetl(&section_id_read,f))
402 {
403 return false;
404 }
405
406 while(!pack_feof(f))
407 {
408 switch(section_id_read)
409 {
410 case ID_RULES:
411 case ID_STRINGS:
412 case ID_MISC:
413 case ID_TILES:
414 case ID_COMBOS:
415 case ID_CSETS:
416 case ID_MAPS:
417 case ID_DMAPS:
418 case ID_DOORS:
419 case ID_ITEMS:
420 case ID_WEAPONS:
421 case ID_COLORS:
422 case ID_ICONS:
423 case ID_INITDATA:
424 case ID_GUYS:
425 case ID_MIDIS:
426 case ID_CHEATS:
427 catchup=false;
428 break;
429
430 default:
431 break;
432 }
433
434
435 while(catchup)
436 {
437 //section id
438 section_id_read=(section_id_read<<8);
439
440 if(!p_getc(&tempbyte,f))
441 {
442 return false;
443 }
444
445 section_id_read+=tempbyte;
446 }
447
448 if(section_id_read==section_id_requested)
449 {
450 return true;
451 }
452 else
453 {
454 //section version info
455 if(!p_igetw(&dummy,f))
456 {
457 return false;
458 }
459
460 if(!p_igetw(&dummy,f))
461 {
462 return false;
463 }
464
465 //section size
466 if(!p_igetl(&section_size,f))
467 {
468 return false;
469 }
470
471 //pack_fseek(f, section_size);
472 while(section_size>65535)
473 {
474 pfread(tempbuf,65535,f);
475 tempbuf[65535]=0;
476 section_size-=65535;
477 }
478
479 if(section_size>0)
480 {
481 pfread(tempbuf,section_size,f);
482 tempbuf[section_size]=0;
483 }
484 }
485
486 //section id
487 if(!p_mgetl(&section_id_read,f))
488 {
489 return false;
490 }
491 }
492
493 return false;
494 }
495
496
497
498
499
500 bool valid_zqt(PACKFILE *f)
501 {
502
503 //word tiles_used;
504 //word combos_used;
505 //open the file
506 //PACKFILE *f = pack_fopen(path, F_READ_PACKED);
507 if(!f)
508 return false;
509
510 //for now, everything else is valid
511 return true;
512
513 /*int16_t version;
514 byte build;
515
516 //read the version and make sure it worked
517 if(!p_igetw(&version,f))
518 {
519 goto error;
520 }
521
522 //read the build and make sure it worked
523 if(!p_getc(&build,f))
524 goto error;
525
526 //read the tile info and make sure it worked
527 if(!p_igetw(&tiles_used,f))
528 {
529 goto error;
530 }
531
532 for (int32_t i=0; i<tiles_used; i++)
533 {
534 if(!pfread(trashbuf,tilesize(tf4Bit),f))
535 {
536 goto error;
537 }
538 }
539
540 //read the combo info and make sure it worked
541 if(!p_igetw(&combos_used,f))
542 {
543 goto error;
544 }
545 for (int32_t i=0; i<combos_used; i++)
546 {
547 if(!pfread(trashbuf,sizeof(newcombo),f))
548 {
549 goto error;
550 }
551 }
552
553 //read the palette info and make sure it worked
554 for (int32_t i=0; i<48; i++)
555 {
556 if(!pfread(trashbuf,newpdTOTAL,f))
557 {
558 goto error;
559 }
560 }
561 if(!pfread(trashbuf,sizeof(palcycle)*256*3,f))
562 {
563 goto error;
564 }
565 for (int32_t i=0; i<MAXLEVELS; i++)
566 {
567 if(!pfread(trashbuf,PALNAMESIZE,f))
568 {
569 goto error;
570 }
571 }
572
573 //read the sprite info and make sure it worked
574 for (int32_t i=0; i<MAXITEMS; i++)
575 {
576 if(!pfread(trashbuf,sizeof(itemdata),f))
577 {
578 goto error;
579 }
580 }
581
582 for (int32_t i=0; i<MAXWPNS; i++)
583 {
584 if(!pfread(trashbuf,sizeof(wpndata),f))
585 {
586 goto error;
587 }
588 }
589
590 //read the triforce pieces info and make sure it worked
591 for (int32_t i=0; i<8; ++i)
592 {
593 if(!p_getc(&trashbuf,f))
594 {
595 goto error;
596 }
597 }
598
599
600
601 //read the game icons info and make sure it worked
602 for (int32_t i=0; i<4; ++i)
603 {
604 if(!p_igetw(&trashbuf,f))
605 {
606 goto error;
607 }
608 }
609
610 //read the misc colors info and map styles info and make sure it worked
611 if(!pfread(trashbuf,sizeof(zcolors),f))
612 {
613 goto error;
614 }
615
616 //read the template screens and make sure it worked
617 byte num_maps;
618 if(!p_getc(&num_maps,f))
619 {
620 goto error;
621 }
622 for (int32_t i=0; i<TEMPLATES; i++)
623 {
624 if(!pfread(trashbuf,sizeof(mapscr),f))
625 {
626 goto error;
627 }
628 }
629 if (num_maps>1) //dungeon templates
630 {
631 for (int32_t i=0; i<TEMPLATES; i++)
632 {
633 if(!pfread(trashbuf,sizeof(mapscr),f))
634 {
635 goto error;
636 }
637 }
638 }
639
640 //yay! it worked! close the file and say everything was ok.
641 pack_fclose(f);
642 return true;
643
644 error:
645 pack_fclose(f);
646 return false;*/
647 }
648
649 bool valid_zqt(const char *filename)
650 {
651 PACKFILE *f=NULL;
652 bool isvalid;
653 int32_t error;
654 f=open_quest_file(&error, filename, false);
655
656 if(!f)
657 {
658 // setPackfilePassword(NULL);
659 return false;
660 }
661
662 isvalid=valid_zqt(f);
663
664 clear_quest_tmpfile();
665 pack_fclose(f);
666
667 // setPackfilePassword(NULL);
668 return isvalid;
669 }
670
671 /*
672 .qst file history
673
674 .qst files have always been compressed using allegro's packfiles.
675
676 At some point, an encoding layer was added. The two layers look like this:
677
678 1) The top layer is from us. See decode_file_007.
679 [0-24] Preamble "Zelda Classic Quest File"
680 [25-28] Initial decoding seed value.
681 [29-X] Allegro-compressed payload (AKA "packed" file), but XOR'd based on seed value
682 [last 4] Checksum
683
684 2) The bottom layer is a "compressed packed file" from Allegro 4. The entire payload
685 is XOR'd with a password (datapwd). Once that is undone, the first four bytes are "slh!",
686 followed by a lzss compressed representation of the payload (from allergo' packfile compression).
687 The oldest quests skip the password part.
688
689 Simply, the job of this function is to peel away the top layer.
690
691 With this second layer of encryption, the data isn't any more secure, and adds a significant delay
692 in opening and saving files. There is no version field, so they decryption key is
693 found via trial-by-error (very slow!)
694
695 There are other file types of interest:
696 - .zqt: quest template files, skips top-layer encryption pass
697 - .qsu: "unencoded" (and uncompressed) files; skips encryption and compression (also makes the longtan password moot)
698 - .qu?: same as above. automated backup files
699 - .qb?: same as above. automated backup files
700 - .qt?: compressed and encrypted (or not encrypted, as of May 2023)
701
702 May 2023: .qst files are now saved without the top layer encoding, and no allegro packfile password. The first bytes of these
703 files are now "slh!.AG ZC Enhanced Quest File".
704 The following command will take an existing qst file and upgrade it: `./zquest -unencrypt-qst <input> <output>`
705 */
706 695 PACKFILE *open_quest_file(int32_t *open_error, const char *filename, bool show_progress)
707 {
708
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 1 times.
695 if (show_progress)
709 {
710 1 box_start(1, "Loading Quest", get_zc_font(font_lfont), font, true);
711 1 }
712
713 695 auto unencrypted_result = try_open_maybe_legacy_encoded_file(filename, ENC_STR, nullptr, QH_NEWIDSTR, QH_IDSTR);
714
2/2
✓ Branch 0 taken 535 times.
✓ Branch 1 taken 160 times.
695 if (unencrypted_result.decoded_pf)
715 535 return unencrypted_result.decoded_pf;
716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if (unencrypted_result.not_found)
717 {
718 *open_error = qe_notfound;
719 return nullptr;
720 }
721
722 // Everything below here is legacy code - recently saved quest files will have
723 // returned by now.
724 // The only replay qst file that is still using this legacy encoding is `link_to_the_zelda.qst`.
725
726 // Note: although this is primarily for loading .qst files, it can also handle all of the
727 // file types mentioned in the comment above. No need to be told if the file being loaded
728 // is encrypted or compressed, we can do some simple and fast checks to determine how to load it.
729 160 bool top_layer_compressed = unencrypted_result.top_layer_compressed;
730 160 bool compressed = unencrypted_result.compressed;
731 160 bool encrypted = unencrypted_result.encrypted;
732
733 char tmpfilename[L_tmpnam];
734 160 temp_name(tmpfilename);
735 char percent_done[30];
736 160 int32_t current_method=0;
737
738 PACKFILE *f;
739 160 const char *passwd= encrypted ? datapwd : "";
740
741 // oldquest flag is set when an unencrypted qst file is suspected.
742 160 bool oldquest = false;
743 int32_t ret;
744
745
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(strcmp(filename, "default.qst")!=0)
746 {
747 160 box_out(filename);
748 160 }
749 else
750 {
751 box_out("new quest"); // Or whatever
752 }
753 160 box_out("...");
754 160 box_eol();
755 160 box_eol();
756
757
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(encrypted)
758 {
759 160 box_out("Decrypting...");
760 160 box_save_x();
761 160 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_MAX-1, top_layer_compressed, passwd);
762
763
2/2
✓ Branch 0 taken 97 times.
✓ Branch 1 taken 63 times.
160 if(ret)
764 {
765
1/3
✓ Branch 0 taken 63 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
63 switch(ret)
766 {
767 case 1:
768 box_out("error.");
769 box_eol();
770 box_end(true);
771 *open_error=qe_notfound;
772 return NULL;
773
774 case 2:
775 box_out("error.");
776 box_eol();
777 box_end(true);
778 *open_error=qe_internal;
779 return NULL;
780 // be sure not to delete tmpfilename now...
781 }
782
783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
784 {
785 63 current_method++;
786 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
787 63 box_out(percent_done);
788 63 box_load_x();
789 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_211B9, strstr(filename, ".dat#")!=NULL, passwd);
790 63 }
791
792
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret==5) //old encryption?
793 {
794 63 current_method++;
795 63 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
796 63 box_out(percent_done);
797 63 box_load_x();
798 63 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B185, strstr(filename, ".dat#")!=NULL, passwd);
799 63 }
800
801
2/2
✓ Branch 0 taken 45 times.
✓ Branch 1 taken 18 times.
63 if(ret==5) //old encryption?
802 {
803 18 current_method++;
804 18 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
805 18 box_out(percent_done);
806 18 box_load_x();
807 18 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B105, strstr(filename, ".dat#")!=NULL, passwd);
808 18 }
809
810
2/2
✓ Branch 0 taken 51 times.
✓ Branch 1 taken 12 times.
63 if(ret==5) //old encryption?
811 {
812 12 current_method++;
813 12 sprintf(percent_done, "%d%%", (current_method*100)/ENC_METHOD_MAX);
814 12 box_out(percent_done);
815 12 box_load_x();
816 12 ret = decode_file_007(filename, tmpfilename, ENC_STR, ENC_METHOD_192B104, strstr(filename, ".dat#")!=NULL, passwd);
817 12 }
818
819
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63 times.
63 if(ret)
820 {
821 oldquest = true;
822 passwd="";
823 }
824 63 }
825
826 160 box_out("okay.");
827 160 box_eol();
828 160 }
829 else
830 {
831 oldquest = true;
832 }
833
834 160 box_out("Opening...");
835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 f = pack_fopen_password(oldquest ? filename : tmpfilename, compressed ? F_READ_PACKED : F_READ, passwd);
836
1/2
✓ Branch 0 taken 160 times.
✗ Branch 1 not taken.
160 if(!f)
837 {
838 if((compressed==1)&&(errno==EDOM))
839 {
840 f = pack_fopen_password(oldquest ? filename : tmpfilename, F_READ, passwd);
841 }
842
843 if(!f)
844 {
845 if(!oldquest)
846 {
847 delete_file(tmpfilename);
848 }
849 box_out("error.");
850 box_eol();
851 box_end(true);
852 *open_error=qe_invalid;
853 return NULL;
854 }
855 }
856
857
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160 times.
160 if(!oldquest)
858 {
859 160 delete_file(tmpfilename);
860 160 }
861
862 160 box_out("okay.");
863 160 box_eol();
864
865 160 return f;
866 695 }
867
868 PACKFILE *open_quest_template(zquestheader *Header, char *deletefilename, bool validate)
869 {
870 char *filename;
871 PACKFILE *f=NULL;
872 int32_t open_error=0;
873
874 strcpy(qstdat_string, "modules/classic/default.qst");
875 if(Header->templatepath[0]==0)
876 {
877 filename=(char *)malloc(2048);
878 strcpy(filename, qstdat_string);
879 }
880 else
881 {
882 // TODO: should be safe to remove this, no one seems to use custom quest templates.
883 filename=Header->templatepath;
884 }
885
886 f=open_quest_file(&open_error, filename, false);
887
888 if(Header->templatepath[0]==0)
889 {
890 free(filename);
891 }
892
893 if(!f)
894 {
895 return NULL;
896 }
897
898 if(validate)
899 {
900 if(!valid_zqt(f))
901 {
902 jwin_alert("Error","Invalid Quest Template",NULL,NULL,"O&K",NULL,'k',0,get_zc_font(font_lfont));
903 pack_fclose(f);
904 clear_quest_tmpfile();
905 return NULL;
906 }
907 }
908
909 return f;
910 }
911
912 bool init_section(zquestheader *Header, int32_t section_id, miscQdata *Misc, zctune *tunes, bool validate)
913 {
914 // We absolutely do not support loading from a template file to initialize data outside the editor.
915 // TODO: move this code into zq/
916 if (get_app_id() != App::zquest) return false;
917
918 combosread=false;
919 mapsread=false;
920 fixffcs=false;
921
922 switch(section_id)
923 {
924 case ID_RULES:
925 case ID_STRINGS:
926 case ID_MISC:
927 case ID_TILES:
928 case ID_COMBOS:
929 case ID_CSETS:
930 case ID_MAPS:
931 case ID_DMAPS:
932 case ID_DOORS:
933 case ID_ITEMS:
934 case ID_WEAPONS:
935 case ID_COLORS:
936 case ID_ICONS:
937 case ID_INITDATA:
938 case ID_GUYS:
939 case ID_MIDIS:
940 case ID_CHEATS:
941 case ID_ITEMDROPSETS:
942 case ID_FAVORITES:
943 break;
944
945 default:
946 return false;
947 break;
948 }
949
950 int32_t ret;
951 word version, build;
952 PACKFILE *f=NULL;
953
954 char deletefilename[1024];
955 deletefilename[0]=0;
956
957 //why is this here?
958 /*
959 if(colordata==NULL)
960 return false;
961 */
962
963 //setPackfilePassword(datapwd);
964 f=open_quest_template(Header, deletefilename, validate);
965
966 if(!f) //no file, nothing to delete
967 {
968 // setPackfilePassword(NULL);
969 return false;
970 }
971
972 ret=get_version_and_build(f, &version, &build);
973
974 if(ret||(version==0))
975 {
976 pack_fclose(f);
977 clear_quest_tmpfile();
978
979 if(deletefilename[0])
980 {
981 delete_file(deletefilename);
982 }
983
984 // setPackfilePassword(NULL);
985 return false;
986 }
987
988 if(!find_section(f, section_id))
989 {
990 al_trace("Can't find section!\n");
991 pack_fclose(f);
992 clear_quest_tmpfile();
993
994 if(deletefilename[0])
995 {
996 delete_file(deletefilename);
997 }
998
999 //setPackfilePassword(NULL);
1000 return false;
1001 }
1002
1003 switch(section_id)
1004 {
1005 case ID_RULES:
1006 //rules
1007 ret=readrules(f, Header);
1008 break;
1009
1010 case ID_STRINGS:
1011 //strings
1012 ret=readstrings(f, Header);
1013 break;
1014
1015 case ID_MISC:
1016 //misc data
1017 ret=readmisc(f, Header, Misc);
1018 break;
1019
1020 case ID_TILES:
1021 //tiles
1022 ret=readtiles(f, newtilebuf, Header, version, build, 0, NEWMAXTILES, true);
1023 break;
1024
1025 case ID_COMBOS:
1026 //combos
1027 clear_combos();
1028 ret=readcombos(f, Header, version, build, 0, MAXCOMBOS);
1029 combosread=true;
1030 break;
1031
1032 case ID_COMBOALIASES:
1033 //combos
1034 ret=readcomboaliases(f, Header, version, build);
1035 break;
1036
1037 case ID_CSETS:
1038 //color data
1039 ret=readcolordata(f, Misc, version, build, 0, newerpdTOTAL);
1040 break;
1041
1042 case ID_MAPS:
1043 //maps
1044 ret=readmaps(f, Header);
1045 mapsread=true;
1046 break;
1047
1048 case ID_DMAPS:
1049 //dmaps
1050 ret=readdmaps(f, Header, version, build, 0, MAXDMAPS);
1051 break;
1052
1053 case ID_DOORS:
1054 //door combo sets
1055 ret=readdoorcombosets(f, Header);
1056 break;
1057
1058 case ID_ITEMS:
1059 //items
1060 ret=readitems(f, version, build);
1061 break;
1062
1063 case ID_WEAPONS:
1064 //weapons
1065 ret=readweapons(f, Header);
1066 break;
1067
1068 case ID_COLORS:
1069 //misc. colors
1070 ret=readmisccolors(f, Header, Misc);
1071 break;
1072
1073 case ID_ICONS:
1074 //game icons
1075 ret=readgameicons(f, Header, Misc);
1076 break;
1077
1078 case ID_INITDATA:
1079 //initialization data
1080 ret=readinitdata(f, Header);
1081 break;
1082
1083 case ID_GUYS:
1084 //guys
1085 ret=readguys(f, Header);
1086 break;
1087
1088 case ID_MIDIS:
1089 //midis
1090 ret=readtunes(f, Header, tunes);
1091 break;
1092
1093 case ID_CHEATS:
1094 //cheat codes
1095 ret=readcheatcodes(f, Header);
1096 break;
1097
1098 case ID_ITEMDROPSETS:
1099 //item drop sets
1100 // Why is this one commented out?
1101 //ret=readitemdropsets(f, (int32_t)version, (word)build);
1102 break;
1103
1104 case ID_FAVORITES:
1105 // favorite combos and aliases
1106 ret=readfavorites(f, version, build);
1107 break;
1108
1109 default:
1110 ret=-1;
1111 break;
1112 }
1113
1114 pack_fclose(f);
1115 clear_quest_tmpfile();
1116
1117 if(deletefilename[0])
1118 {
1119 delete_file(deletefilename);
1120 }
1121
1122 //setPackfilePassword(NULL);
1123 if(!ret)
1124 {
1125 return true;
1126 }
1127
1128 return false;
1129 }
1130
1131 bool init_tiles(bool validate, zquestheader *Header)
1132 {
1133 return init_section(Header, ID_TILES, NULL, NULL, validate);
1134 }
1135
1136 bool init_combos(bool validate, zquestheader *Header)
1137 {
1138 return init_section(Header, ID_COMBOS, NULL, NULL, validate);
1139 }
1140
1141 bool init_colordata(bool validate, zquestheader *Header, miscQdata *Misc)
1142 {
1143 return init_section(Header, ID_CSETS, Misc, NULL, validate);
1144 }
1145
1146 695 void init_spritelists()
1147 {
1148
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 423 times.
695 if(FFCore.quest_format[vZelda] < 0x255)
1149 {
1150 272 guys.setMax(255);
1151 272 items.setMax(255);
1152 272 Ewpns.setMax(255);
1153 272 Lwpns.setMax(255);
1154 272 chainlinks.setMax(255);
1155 272 decorations.setMax(255);
1156 272 particles.setMax(255);
1157 272 }
1158 else
1159 {
1160 423 guys.setMax(255);
1161 423 items.setMax(255);
1162 423 Ewpns.setMax(255);
1163 423 Lwpns.setMax(255);
1164 423 chainlinks.setMax(255);
1165 423 decorations.setMax(255);
1166 423 particles.setMax(255*((255*4)+1)); //255 per sprite that can use particles; guys, items, ewpns, lwpns, +HERO
1167 }
1168 695 }
1169
1170 266 bool reset_items(bool validate, zquestheader *Header)
1171 {
1172 266 bool ret = true;
1173
1/2
✓ Branch 0 taken 266 times.
✗ Branch 1 not taken.
266 if (get_app_id() == App::zquest)
1174 ret = init_section(Header, ID_ITEMS, NULL, NULL, validate);
1175
1176
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 68096 times.
68362 for(int32_t i=0; i<MAXITEMS; i++) reset_itemname(i);
1177
1178 266 return ret;
1179 }
1180
1181 bool reset_guys()
1182 {
1183 // The .dat file's guys definitions are always synchronised with defdata.cpp's - even the tile settings.
1184 init_guys(V_GUYS);
1185 return true;
1186 }
1187
1188 bool reset_wpns(bool validate, zquestheader *Header)
1189 {
1190 bool ret = true;
1191 if (get_app_id() == App::zquest)
1192 ret = init_section(Header, ID_WEAPONS, NULL, NULL, validate);
1193
1194 for(int32_t i=0; i<MAXWPNS; i++)
1195 reset_weaponname(i);
1196
1197 return ret;
1198 }
1199
1200 bool reset_mapstyles(bool validate, miscQdata *Misc)
1201 {
1202 Misc->colors.blueframe_tile = 20044;
1203 Misc->colors.blueframe_cset = 0;
1204 Misc->colors.triforce_tile = 23461;
1205 Misc->colors.triforce_cset = 1;
1206 Misc->colors.triframe_tile = 18752;
1207 Misc->colors.triframe_cset = 1;
1208 Misc->colors.overworld_map_tile = 16990;
1209 Misc->colors.overworld_map_cset = 2;
1210 Misc->colors.HCpieces_tile = 21160;
1211 Misc->colors.HCpieces_cset = 8;
1212 Misc->colors.dungeon_map_tile = 19651;
1213 Misc->colors.dungeon_map_cset = 8;
1214 return true;
1215 }
1216
1217 314 int32_t get_qst_buffers()
1218 {
1219 314 TheMaps.resize(MAPSCRS);
1220 314 map_autolayers.resize(6);
1221
1222
2/2
✓ Branch 0 taken 42704 times.
✓ Branch 1 taken 314 times.
43018 for(int32_t i(0); i<MAPSCRS; i++)
1223 42704 TheMaps[i].zero_memory();
1224
1225 //memset(TheMaps, 0, sizeof(mapscr)*MAPSCRS); //shouldn't need this anymore
1226 314 Z_message("OK\n");
1227
1228 // The vast majority of finished quests (and I presume this will be consistent for all time) use < 1000 strings in total.
1229 // (Shoelace's "Hero of Dreams" uses 1415.)
1230 // So let's be a bit generous and allow 4096 initially.
1231 // In the rare event that a quest overshoots this mark, we'll reallocate to the full 65535 later.
1232 // I tested it and it worked without flaw on 6/6/11. - L.
1233 // 2022: bumped from 4096 to 8192 to avoid a bug where the Strings menu shows (None) strings when the list passes
1234 // this threshold. Possibly some bug related to `msglistcache` to being reset?
1235 // See https://discord.com/channels/876899628556091432/992984989073416242
1236 314 msg_strings_size = 8192;
1237
1238
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 MsgStrings = new MsgStr[msg_strings_size];
1239
1240 //memset(MsgStrings, 0, sizeof(MsgStr)*msg_strings_size);
1241
2/2
✓ Branch 0 taken 2572288 times.
✓ Branch 1 taken 314 times.
2572602 for(auto q = 0; q < msg_strings_size; ++q)
1242 {
1243 2572288 MsgStrings[q].clear();
1244 2572288 }
1245
1246
1247
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if((DoorComboSets=(DoorComboSet*)malloc(sizeof(DoorComboSet)*MAXDOORCOMBOSETS))==NULL)
1248 return 0;
1249
1250
1251
1252
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if((DMaps=new dmap[MAXDMAPS])==NULL)
1253 return 0;
1254
1255
1256
1257 314 combobuf.clear();
1258 314 combobuf.resize(MAXCOMBOS);
1259
1260
1261
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if((colordata=(byte*)malloc(psTOTAL255))==NULL)
1262 return 0;
1263
1264 314 free_newtilebuf();
1265
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if((newtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1266 return 0;
1267
1268 314 memset(newtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1269 //Z_message("Performed memset on tiles\n");
1270 314 clear_tiles(newtilebuf);
1271 //Z_message("Performed clear_tiles()\n");
1272
1273
2/2
✓ Branch 0 taken 304 times.
✓ Branch 1 taken 10 times.
314 if(is_editor())
1274 {
1275
1/2
✓ Branch 0 taken 10 times.
✗ Branch 1 not taken.
10 if((grabtilebuf=(tiledata*)malloc(NEWMAXTILES*sizeof(tiledata)))==NULL)
1276 return 0;
1277
1278 10 memset(grabtilebuf, 0, NEWMAXTILES*sizeof(tiledata));
1279 10 clear_tiles(grabtilebuf);
1280 10 }
1281
1282
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if((trashbuf=(byte*)malloc(100000))==NULL)
1283 return 0;
1284
1285 // Big, ugly band-aid here. Perhaps the most common cause of random crashes
1286 // has been inadvertently accessing itemsbuf[-1]. All such crashes should be
1287 // fixed by ensuring there's actually itemdata there.
1288 // If you change this, be sure to update del_qst_buffers, too.
1289
1290
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if((itemsbuf=(itemdata*)malloc(sizeof(itemdata)*(MAXITEMS+1)))==NULL)
1291 return 0;
1292
1293 314 memset(itemsbuf,0,sizeof(itemdata)*(MAXITEMS+1));
1294 314 itemsbuf++;
1295
1296
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if((wpnsbuf=(wpndata*)malloc(sizeof(wpndata)*MAXWPNS))==NULL)
1297 return 0;
1298
1299 314 memset(wpnsbuf,0,sizeof(wpndata)*MAXWPNS);
1300
1301
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if((guysbuf=(guydata*)malloc(sizeof(guydata)*MAXGUYS))==NULL)
1302 return 0;
1303
1304 314 memset(guysbuf,0,sizeof(guydata)*MAXGUYS);
1305
1306
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 314 times.
314 if((combo_class_buf=(comboclass*)malloc(sizeof(comboclass)*cMAX))==NULL)
1307 return 0;
1308
1309 314 return 1;
1310 314 }
1311
1312
1313 314 void free_newtilebuf()
1314 {
1315
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 313 times.
314 if(newtilebuf)
1316 {
1317
2/2
✓ Branch 0 taken 214500 times.
✓ Branch 1 taken 1 times.
214501 for(int32_t i=0; i<NEWMAXTILES; i++)
1318
1/2
✓ Branch 0 taken 214500 times.
✗ Branch 1 not taken.
214500 if(newtilebuf[i].data)
1319 free(newtilebuf[i].data);
1320
1321 1 free(newtilebuf);
1322 1 newtilebuf = 0;
1323 1 }
1324 314 }
1325
1326 void free_grabtilebuf()
1327 {
1328 if(is_editor())
1329 {
1330 if(grabtilebuf)
1331 {
1332 for(int32_t i=0; i<NEWMAXTILES; i++)
1333 if(grabtilebuf[i].data) free(grabtilebuf[i].data);
1334
1335 free(grabtilebuf);
1336 grabtilebuf = 0;
1337 }
1338 }
1339 }
1340
1341 void del_qst_buffers()
1342 {
1343 if(MsgStrings) delete[] MsgStrings;
1344
1345 if(DoorComboSets) free(DoorComboSets);
1346
1347 if (DMaps) delete[] DMaps;
1348
1349 combobuf.clear();
1350
1351 if(colordata) free(colordata);
1352
1353 free_newtilebuf();
1354 free_grabtilebuf();
1355
1356 if(trashbuf) free(trashbuf);
1357
1358 // See get_qst_buffers
1359 if(itemsbuf)
1360 {
1361 itemsbuf--;
1362 free(itemsbuf);
1363 }
1364
1365 if(wpnsbuf) free(wpnsbuf);
1366
1367 if(guysbuf) free(guysbuf);
1368
1369 if(combo_class_buf) free(combo_class_buf);
1370 }
1371
1372 18 bool init_palnames()
1373 {
1374 // if(palnames==NULL)
1375 // return false;
1376
1377
2/2
✓ Branch 0 taken 9216 times.
✓ Branch 1 taken 18 times.
9234 for(int32_t x=0; x<MAXLEVELS; x++)
1378 {
1379
4/4
✓ Branch 0 taken 9162 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 18 times.
9216 switch(x)
1380 {
1381 case 0:
1382 18 sprintf(palnames[x],"Overworld");
1383 18 break;
1384
1385 case 10:
1386 18 sprintf(palnames[x],"Caves");
1387 18 break;
1388
1389 case 11:
1390 18 sprintf(palnames[x],"Passageways");
1391 18 break;
1392
1393 default:
1394 9162 sprintf(palnames[x],"%c",0);
1395 9162 break;
1396 }
1397 9216 }
1398
1399 18 return true;
1400 }
1401
1402 97803 static void *read_block(PACKFILE *f, int32_t size, int32_t alloc_size)
1403 {
1404 void *p;
1405
1406
1/2
✓ Branch 0 taken 97803 times.
✗ Branch 1 not taken.
97803 p = _AL_MALLOC(MAX(size, alloc_size));
1407
1408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 97803 times.
97803 if(!p)
1409 {
1410 return NULL;
1411 }
1412
1413
1/2
✓ Branch 0 taken 97803 times.
✗ Branch 1 not taken.
97803 if(!pfread(p,size,f))
1414 {
1415 _AL_FREE(p);
1416 return NULL;
1417 }
1418
1419
1/2
✓ Branch 0 taken 97803 times.
✗ Branch 1 not taken.
97803 if(pack_ferror(f))
1420 {
1421 _AL_FREE(p);
1422 return NULL;
1423 }
1424
1425 97803 return p;
1426 97803 }
1427
1428 // Only use for reading parts of older quests (Header->zelda_version <= 0x192)
1429 static const byte* legacy_skip_flags;
1430
1431 /* read_midi:
1432 * Reads MIDI data from a datafile (this is not the same thing as the
1433 * standard midi file format).
1434 */
1435
1436 10243 static MIDI *read_midi(PACKFILE *f)
1437 {
1438 MIDI *m;
1439 int32_t c;
1440 10243 int16_t divisions=0;
1441 10243 int32_t len=0;
1442
1443 10243 m = (MIDI*)_AL_MALLOC(sizeof(MIDI));
1444
1445
1/2
✓ Branch 0 taken 10243 times.
✗ Branch 1 not taken.
10243 if(!m)
1446 {
1447 return NULL;
1448 }
1449
1450
2/2
✓ Branch 0 taken 327776 times.
✓ Branch 1 taken 10243 times.
338019 for(c=0; c<MIDI_TRACKS; c++)
1451 {
1452 327776 m->track[c].len = 0;
1453 327776 m->track[c].data = NULL;
1454 327776 }
1455
1456 10243 p_mgetw(&divisions,f);
1457 10243 m->divisions=divisions;
1458
1459
2/2
✓ Branch 0 taken 327776 times.
✓ Branch 1 taken 10243 times.
338019 for(c=0; c<MIDI_TRACKS; c++)
1460 {
1461 327776 p_mgetl(&len,f);
1462 327776 m->track[c].len=len;
1463
1464
2/2
✓ Branch 0 taken 229973 times.
✓ Branch 1 taken 97803 times.
327776 if(m->track[c].len > 0)
1465 {
1466 97803 m->track[c].data = (byte*)read_block(f, m->track[c].len, 0);
1467
1468
1/2
✓ Branch 0 taken 97803 times.
✗ Branch 1 not taken.
97803 if(!m->track[c].data)
1469 {
1470 destroy_midi(m);
1471 return NULL;
1472 }
1473 97803 }
1474 327776 }
1475
1476 LOCK_DATA(m, sizeof(MIDI));
1477
1478
2/2
✓ Branch 0 taken 327776 times.
✓ Branch 1 taken 10243 times.
338019 for(c=0; c<MIDI_TRACKS; c++)
1479 {
1480
2/2
✓ Branch 0 taken 97803 times.
✓ Branch 1 taken 229973 times.
327776 if(m->track[c].data)
1481 {
1482 LOCK_DATA(m->track[c].data, m->track[c].len);
1483 97803 }
1484 327776 }
1485
1486 10243 return m;
1487 10243 }
1488
1489 void clear_combo(int32_t i)
1490 {
1491 combobuf[i].clear();
1492 }
1493
1494 void clear_combos()
1495 {
1496 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
1497 clear_combo(tmpcounter);
1498 }
1499
1500 void pack_combos()
1501 {
1502 int32_t di = 0;
1503
1504 for(int32_t si=0; si<1024; si+=2)
1505 combobuf[di++] = combobuf[si];
1506
1507 for(; di<1024; di++)
1508 clear_combo(di);
1509 }
1510
1511 694 void reset_tunes(zctune *tune)
1512 {
1513
2/2
✓ Branch 0 taken 174888 times.
✓ Branch 1 taken 694 times.
175582 for(int32_t i=0; i<MAXCUSTOMTUNES; i++)
1514 {
1515 174888 tune[i].reset();
1516 174888 }
1517 694 }
1518
1519
1520 /*void reset_midi(zcmidi_ *m)
1521 {
1522 m->title[0]=0;
1523 m->loop=1;
1524 m->volume=144;
1525 m->start=0;
1526 m->loop_start=-1;
1527 m->loop_end=-1;
1528 if(m->midi)
1529 {
1530 destroy_midi(m->midi);
1531 }
1532 m->midi=NULL;
1533 }
1534
1535
1536 void reset_midis(zcmidi_ *m)
1537 {
1538 for(int32_t i=0; i<MAXCUSTOMMIDIS; i++)
1539 {
1540 reset_midi(m+i);
1541 }
1542 }
1543 */
1544
1545 void reset_scr(int32_t scr)
1546 {
1547 /*
1548 byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1549 for(unsigned i=0; i<sizeof(mapscr); i++)
1550 *(di++) = 0;
1551 TheMaps[scr].valid=mVERSION;
1552 */
1553
1554 TheMaps[scr].zero_memory();
1555 //byte *di=((byte*)TheMaps)+(scr*sizeof(mapscr));
1556
1557 for(int32_t i=0; i<6; i++)
1558 {
1559 //these will be uncommented later
1560 //TheMaps[scr].layerxsize[i]=16;
1561 //TheMaps[scr].layerysize[i]=11;
1562 TheMaps[scr].layeropacity[i]=255;
1563 }
1564
1565 TheMaps[scr].valid=mVERSION;
1566
1567 }
1568
1569 /* For reference:
1570
1571 enum { qe_OK, qe_notfound, qe_invalid, qe_version, qe_obsolete,
1572 qe_missing, qe_internal, qe_pwd, qe_match, qe_minver };
1573 */
1574
1575 28922 int32_t operator ==(DoorComboSet a, DoorComboSet b)
1576 {
1577
2/2
✓ Branch 0 taken 63938 times.
✓ Branch 1 taken 4377 times.
68315 for(int32_t i=0; i<9; i++)
1578 {
1579
2/2
✓ Branch 0 taken 262433 times.
✓ Branch 1 taken 39699 times.
302132 for(int32_t j=0; j<6; j++)
1580 {
1581
2/2
✓ Branch 0 taken 79398 times.
✓ Branch 1 taken 183035 times.
262433 if(j<4)
1582 {
1583
2/2
✓ Branch 0 taken 158796 times.
✓ Branch 1 taken 24239 times.
183035 if(a.doorcombo_u[i][j]!=b.doorcombo_u[i][j])
1584 {
1585 24239 return false;
1586 }
1587
1588
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcset_u[i][j]!=b.doorcset_u[i][j])
1589 {
1590 return false;
1591 }
1592
1593
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcombo_d[i][j]!=b.doorcombo_d[i][j])
1594 {
1595 return false;
1596 }
1597
1598
1/2
✓ Branch 0 taken 158796 times.
✗ Branch 1 not taken.
158796 if(a.doorcset_d[i][j]!=b.doorcset_d[i][j])
1599 {
1600 return false;
1601 }
1602 158796 }
1603
1604
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcombo_l[i][j]!=b.doorcombo_l[i][j])
1605 {
1606 return false;
1607 }
1608
1609
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcset_l[i][j]!=b.doorcset_l[i][j])
1610 {
1611 return false;
1612 }
1613
1614
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcombo_r[i][j]!=b.doorcombo_r[i][j])
1615 {
1616 return false;
1617 }
1618
1619
1/2
✓ Branch 0 taken 238194 times.
✗ Branch 1 not taken.
238194 if(a.doorcset_r[i][j]!=b.doorcset_r[i][j])
1620 {
1621 return false;
1622 }
1623 238194 }
1624
1625
2/2
✓ Branch 0 taken 30639 times.
✓ Branch 1 taken 9060 times.
39699 if(i<2)
1626 {
1627
1/2
✓ Branch 0 taken 9060 times.
✗ Branch 1 not taken.
9060 if(a.flags[i]!=b.flags[i])
1628 {
1629 return false;
1630 }
1631
1632
2/2
✓ Branch 0 taken 9036 times.
✓ Branch 1 taken 24 times.
9060 if(a.bombdoorcombo_u[i]!=b.bombdoorcombo_u[i])
1633 {
1634 24 return false;
1635 }
1636
1637
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcset_u[i]!=b.bombdoorcset_u[i])
1638 {
1639 return false;
1640 }
1641
1642
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcombo_d[i]!=b.bombdoorcombo_d[i])
1643 {
1644 return false;
1645 }
1646
1647
1/2
✓ Branch 0 taken 9036 times.
✗ Branch 1 not taken.
9036 if(a.bombdoorcset_d[i]!=b.bombdoorcset_d[i])
1648 {
1649 return false;
1650 }
1651 9036 }
1652
1653
2/2
✓ Branch 0 taken 26262 times.
✓ Branch 1 taken 13413 times.
39675 if(i<3)
1654 {
1655
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcombo_l[i]!=b.bombdoorcombo_l[i])
1656 {
1657 return false;
1658 }
1659
1660
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcset_l[i]!=b.bombdoorcset_l[i])
1661 {
1662 return false;
1663 }
1664
1665
1/2
✓ Branch 0 taken 13413 times.
✗ Branch 1 not taken.
13413 if(a.bombdoorcombo_r[i]!=b.bombdoorcombo_r[i])
1666 {
1667 return false;
1668 }
1669
1670
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13413 times.
13413 if(a.bombdoorcset_r[i]!=b.bombdoorcset_r[i])
1671 {
1672 return false;
1673 }
1674 13413 }
1675
1676
2/2
✓ Branch 0 taken 39393 times.
✓ Branch 1 taken 282 times.
39675 if(a.walkthroughcombo[i]!=b.walkthroughcombo[i])
1677 {
1678 282 return false;
1679 }
1680
1681
1/2
✓ Branch 0 taken 39393 times.
✗ Branch 1 not taken.
39393 if(a.walkthroughcset[i]!=b.walkthroughcset[i])
1682 {
1683 return false;
1684 }
1685 39393 }
1686
1687 4377 return true;
1688 28922 }
1689
1690 int32_t doortranslations_u[9][4]=
1691 {
1692 {37,38,53,54},
1693 {37,38,39,40},
1694 {37,38,55,56},
1695 {37,38,39,40},
1696 {37,38,53,54},
1697 {37,38,53,54},
1698 {37,38,53,54},
1699 {7,8,23,24},
1700 {7,8,41,42}
1701 };
1702
1703 int32_t doortranslations_d[9][4]=
1704 {
1705 {117,118,133,134},
1706 {135,136,133,134},
1707 {119,120,133,134},
1708 {135,136,133,134},
1709 {117,118,133,134},
1710 {117,118,133,134},
1711 {117,118,133,134},
1712 {151,152,167,168},
1713 {137,138,167,168},
1714 };
1715
1716 //enum {dt_pass=0, dt_lock, dt_shut, dt_boss, dt_olck, dt_osht, dt_obos, dt_wall, dt_bomb, dt_walk, dt_max};
1717 int32_t doortranslations_l[9][6]=
1718 {
1719 {66,67,82,83,98,99},
1720 {66,68,82,84,98,100},
1721 {66,69,82,85,98,101},
1722 {66,68,82,84,98,100},
1723 {66,67,82,83,98,99},
1724 {66,67,82,83,98,99},
1725 {66,67,82,83,98,99},
1726 {64,65,80,81,96,97},
1727 {64,65,80,114,96,97},
1728 };
1729
1730 int32_t doortranslations_r[9][6]=
1731 {
1732
1733 {76,77,92,93,108,109},
1734 {75,77,91,93,107,109},
1735 {74,77,90,93,106,109},
1736 {75,77,91,93,107,109},
1737 {76,77,92,93,108,109},
1738 {76,77,92,93,108,109},
1739 {76,77,92,93,108,109},
1740 {78,79,94,95,110,111},
1741 {78,79,125,95,110,111},
1742 };
1743
1744 858450 int32_t tdcmbdat(int32_t map, int32_t scr, int32_t pos)
1745 {
1746 858450 return (TheMaps[map*MAPSCRS+TEMPLATE].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1747 }
1748
1749 840750 int32_t tdcmbcset(int32_t map, int32_t scr, int32_t pos)
1750 {
1751 //these are here to bypass compiler warnings about unused arguments
1752 840750 map=map;
1753 840750 scr=scr;
1754 840750 pos=pos;
1755
1756 //what does this function do?
1757 // return TheMaps[map*MAPSCRS+TEMPLATE].cset[pos];
1758 840750 return 2;
1759 }
1760
1761 22848 int32_t MakeDoors(int32_t map, int32_t scr)
1762 {
1763
2/2
✓ Branch 0 taken 18423 times.
✓ Branch 1 taken 4425 times.
22848 if(!(TheMaps[map*MAPSCRS+scr].valid&mVALID))
1764 {
1765 18423 return 0;
1766 }
1767
1768 DoorComboSet tempdcs;
1769 4425 memset(&tempdcs, 0, sizeof(DoorComboSet));
1770
1771 //up
1772
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1773 {
1774
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1775 {
1776 159300 tempdcs.doorcombo_u[i][j]=tdcmbdat(map,scr,doortranslations_u[i][j]);
1777 159300 tempdcs.doorcset_u[i][j]=tdcmbcset(map,scr,doortranslations_u[i][j]);
1778 159300 }
1779 39825 }
1780
1781 4425 tempdcs.bombdoorcombo_u[0]=tdcmbdat(map,scr,57);
1782 4425 tempdcs.bombdoorcset_u[0]=tdcmbcset(map,scr,57);
1783 4425 tempdcs.bombdoorcombo_u[1]=tdcmbdat(map,scr,58);
1784 4425 tempdcs.bombdoorcset_u[1]=tdcmbcset(map,scr,58);
1785 4425 tempdcs.walkthroughcombo[0]=tdcmbdat(map,scr,34);
1786 4425 tempdcs.walkthroughcset[0]=tdcmbdat(map,scr,34);
1787
1788 //down
1789
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1790 {
1791
2/2
✓ Branch 0 taken 159300 times.
✓ Branch 1 taken 39825 times.
199125 for(int32_t j=0; j<4; j++)
1792 {
1793 159300 tempdcs.doorcombo_d[i][j]=tdcmbdat(map,scr,doortranslations_d[i][j]);
1794 159300 tempdcs.doorcset_d[i][j]=tdcmbcset(map,scr,doortranslations_d[i][j]);
1795 159300 }
1796 39825 }
1797
1798 4425 tempdcs.bombdoorcombo_d[0]=tdcmbdat(map,scr,121);
1799
1800 4425 tempdcs.bombdoorcset_d[0]=tdcmbcset(map,scr,121);
1801 4425 tempdcs.bombdoorcombo_d[1]=tdcmbdat(map,scr,122);
1802 4425 tempdcs.bombdoorcset_d[1]=tdcmbcset(map,scr,122);
1803 4425 tempdcs.walkthroughcombo[1]=tdcmbdat(map,scr,34);
1804 4425 tempdcs.walkthroughcset[1]=tdcmbdat(map,scr,34);
1805
1806 //left
1807 // TheMaps[i*MAPSCRS+j].warpdmap=TheOldMap.warpdmap;
1808
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1809 {
1810
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1811 {
1812 238950 tempdcs.doorcombo_l[i][j]=tdcmbdat(map,scr,doortranslations_l[i][j]);
1813 238950 tempdcs.doorcset_l[i][j]=tdcmbcset(map,scr,doortranslations_l[i][j]);
1814 238950 }
1815 39825 }
1816
1817
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1818 {
1819 if((j!=2)&&(j!=3))
1820 {
1821 tempdcs.doorcombo_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_l[dt_bomb][j]];
1822 tempdcs.doorcset_l[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_l[dt_bomb][j]];
1823 }
1824 }
1825
1826 4425 tempdcs.bombdoorcombo_l[0]=0;
1827 4425 tempdcs.bombdoorcset_l[0]=tdcmbcset(map,scr,115);
1828 4425 tempdcs.bombdoorcombo_l[1]=tdcmbdat(map,scr,115);
1829 4425 tempdcs.bombdoorcset_l[1]=tdcmbcset(map,scr,115);
1830 4425 tempdcs.bombdoorcombo_l[2]=0;
1831 4425 tempdcs.bombdoorcset_l[2]=tdcmbcset(map,scr,115);
1832 4425 tempdcs.walkthroughcombo[2]=tdcmbdat(map,scr,34);
1833 4425 tempdcs.walkthroughcset[2]=tdcmbdat(map,scr,34);
1834
1835 //right
1836
2/2
✓ Branch 0 taken 39825 times.
✓ Branch 1 taken 4425 times.
44250 for(int32_t i=0; i<9; i++)
1837 {
1838
2/2
✓ Branch 0 taken 238950 times.
✓ Branch 1 taken 39825 times.
278775 for(int32_t j=0; j<6; j++)
1839 {
1840 238950 tempdcs.doorcombo_r[i][j]=tdcmbdat(map,scr,doortranslations_r[i][j]);
1841 238950 tempdcs.doorcset_r[i][j]=tdcmbcset(map,scr,doortranslations_r[i][j]);
1842 238950 }
1843 39825 }
1844
1845
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4425 times.
4425 for(int32_t j=0; j>6; j++)
1846 {
1847 if((j!=2)&&(j!=3))
1848 {
1849 tempdcs.doorcombo_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].data[doortranslations_r[dt_bomb][j]];
1850 tempdcs.doorcset_r[dt_bomb][j]=TheMaps[map*MAPSCRS+scr].cset[doortranslations_r[dt_bomb][j]];
1851 }
1852 }
1853
1854 4425 tempdcs.bombdoorcombo_r[0]=0;
1855 4425 tempdcs.bombdoorcset_r[0]=tdcmbcset(map,scr,124);
1856 4425 tempdcs.bombdoorcombo_r[1]=tdcmbdat(map,scr,124);
1857 4425 tempdcs.bombdoorcset_r[1]=tdcmbcset(map,scr,124);
1858 4425 tempdcs.bombdoorcombo_r[2]=0;
1859 4425 tempdcs.bombdoorcset_r[2]=tdcmbcset(map,scr,124);
1860 4425 tempdcs.walkthroughcombo[3]=tdcmbdat(map,scr,34);
1861 4425 tempdcs.walkthroughcset[3]=tdcmbdat(map,scr,34);
1862
1863 int32_t k;
1864
1865
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 28922 times.
28970 for(k=0; k<door_combo_set_count; k++)
1866 {
1867
2/2
✓ Branch 0 taken 4377 times.
✓ Branch 1 taken 24545 times.
28922 if(DoorComboSets[k]==tempdcs)
1868 {
1869 4377 break;
1870 }
1871 24545 }
1872
1873
2/2
✓ Branch 0 taken 4377 times.
✓ Branch 1 taken 48 times.
4425 if(k==door_combo_set_count)
1874 {
1875 48 DoorComboSets[k]=tempdcs;
1876 48 sprintf(DoorComboSets[k].name, "Door Combo Set %d", k);
1877 48 ++door_combo_set_count;
1878 48 }
1879
1880 4425 return k;
1881 /*
1882 doorcombo_u[9][4];
1883 doorcset_u[9][4];
1884 doorcombo_d[9][4];
1885 doorcset_d[9][4];
1886 doorcombo_l[9][6];
1887 doorcset_l[9][6];
1888 doorcombo_r[9][6];
1889 doorcset_r[9][6];
1890 bombdoorcombo_u[2];
1891 bombdoorcset_u[2];
1892 bombdoorcombo_d[2];
1893 bombdoorcset_d[2];
1894 bombdoorcombo_l[3];
1895 bombdoorcset_l[3];
1896 bombdoorcombo_r[3];
1897 bombdoorcset_r[3];
1898 walkthroughcombo[4];
1899 walkthroughcset[4];
1900 */
1901 22848 }
1902
1903 2924544 INLINE int32_t tcmbdat2(int32_t map, int32_t scr, int32_t pos)
1904 {
1905 2924544 return (TheMaps[map*MAPSCRS+TEMPLATE2].data[pos]&0xFF)+((TheMaps[map*MAPSCRS+scr].old_cpage)<<8);
1906 }
1907
1908 2924544 INLINE int32_t tcmbcset2(int32_t map, int32_t pos)
1909 {
1910
1911 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].cset[pos];
1912 }
1913
1914 2924544 INLINE int32_t tcmbflag2(int32_t map, int32_t pos)
1915 {
1916 2924544 return TheMaps[map*MAPSCRS+TEMPLATE2].sflag[pos];
1917 }
1918
1919
1920 83 void get_questpwd(char *encrypted_pwd, int16_t pwdkey, char *pwd)
1921 {
1922 char temp_pwd[30];
1923 83 memset(temp_pwd,0,30);
1924
1925
2/2
✓ Branch 0 taken 75 times.
✓ Branch 1 taken 8 times.
83 if(pwdkey!=0)
1926 {
1927 75 memcpy(temp_pwd,encrypted_pwd,30);
1928 75 temp_pwd[29]=0;
1929
1930
2/2
✓ Branch 0 taken 2250 times.
✓ Branch 1 taken 75 times.
2325 for(int32_t i=0; i<30; i++)
1931 {
1932 2250 temp_pwd[i] -= pwdkey;
1933 2250 int32_t t=pwdkey>>15;
1934 2250 pwdkey = (pwdkey<<1)+t;
1935 2250 }
1936 75 }
1937
1938 83 memcpy(pwd,temp_pwd,30);
1939 83 }
1940
1941
1942 267 bool devpwd()
1943 {
1944 #ifdef _DEBUG
1945 return true;
1946 #endif
1947 #if DEVLEVEL > 3
1948 return true;
1949 #endif
1950
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 return !strcmp(zc_get_config("dev","pwd","",App::zquest), (char*)clavio) || is_ci();
1951 }
1952 bool check_questpwd(zquestheader *Header, char *pwd)
1953 {
1954 if(devpwd())
1955 return true;
1956 if((!strcmp(pwd, (char*)clavio)))
1957 return true;
1958 cvs_MD5Context ctx;
1959 uint8_t md5sum[16];
1960
1961 cvs_MD5Init(&ctx);
1962 cvs_MD5Update(&ctx, (const uint8_t*)pwd, (unsigned)strlen(pwd));
1963 cvs_MD5Final(md5sum, &ctx);
1964
1965 return (memcmp(Header->pwd_hash,md5sum,16)==0);
1966 }
1967
1968 static char const* key_exts[KEYFILE_NUMTY] = {"key", "zcheat", "zpwd"};
1969 static bool key_hashed[KEYFILE_NUMTY] = {false, true, false};
1970 static char const* key_namestr[KEYFILE_NUMTY] = {"Master","Cheat","ZPwd"};
1971
1972 static bool check_keyfile(char const* path, char const* ext, bool hashed, char const* typestr, zquestheader* Header)
1973 {
1974 char keyfilename[2048];
1975 replace_extension(keyfilename, path, ext, 2047);
1976 if(!exists(keyfilename))
1977 return false;
1978 bool ret = false;
1979
1980 char password[QSTPWD_LEN] = {0}, pwd[32] = {0};
1981 PACKFILE *fp = pack_fopen_password(keyfilename, F_READ,"");
1982 char msg[80] = {0};
1983 pfread(msg, 80, fp);
1984 if(strcmp(msg,"ZQuest Auto-Generated Quest Password Key File. DO NOT EDIT!"))
1985 {
1986 zprint2("Found %s Key File '%s' (invalid header)\n", typestr, keyfilename);
1987 pack_fclose(fp);
1988 return false;
1989 }
1990 int16_t ver;
1991 byte bld;
1992 p_igetw(&ver, fp);
1993 p_getc(&bld, fp);
1994 pfread(password, QSTPWD_LEN, fp, true);
1995 if(hashed)
1996 {
1997 char unhashed_pw[QSTPWD_LEN] = {0};
1998
1999 char hashmap = 'Z';
2000 hashmap += 'Q';
2001 hashmap += 'U';
2002 hashmap += 'E';
2003 hashmap += 'S';
2004 hashmap += 'T';
2005
2006 for ( int32_t q = 0; q < QSTPWD_LEN; ++q )
2007 unhashed_pw[q] = password[q] - hashmap;
2008
2009 ret = check_questpwd(Header, unhashed_pw);
2010 }
2011 else ret = check_questpwd(Header, password);
2012 pack_fclose(fp);
2013 zprint2("Found %s Key File '%s' (%s access)\n",
2014 typestr, keyfilename, ret ? "valid" : "invalid");
2015 return ret;
2016 }
2017
2018 bool check_keyfiles(char const* path, vector<uint> types, zquestheader* Header)
2019 {
2020 char exedir[PATH_MAX] = {0};
2021 extract_name(path, exedir, FILENAMEALL);
2022 char const* paths[] = {path, exedir};
2023 for(uint keyty : types)
2024 {
2025 if(keyty >= KEYFILE_NUMTY)
2026 continue;
2027 for(char const* p : paths)
2028 {
2029 if(check_keyfile(p, key_exts[keyty], key_hashed[keyty], key_namestr[keyty], Header))
2030 return true;
2031 }
2032 }
2033 return false;
2034 }
2035
2036 381 void print_quest_metadata(zquestheader const& tempheader, char const* path, byte qst_num)
2037 {
2038 381 zprint2("\n");
2039 381 zprint2("[QUEST METADATA]\n");
2040
2/2
✓ Branch 0 taken 372 times.
✓ Branch 1 taken 9 times.
381 if(qst_num < moduledata.max_quest_files)
2041 9 zprint2("Loading module quest %d\n", qst_num+1);
2042
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 381 times.
381 if(path) zprint2("Loading '%s'\n", path);
2043 381 zprint2("Last saved in version %s\n", tempheader.getVerStr());
2044
2045
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 138 times.
381 if ( tempheader.made_in_module_name[0] ) zprint2("Created with ZC Module: %s\n\n", tempheader.made_in_module_name);
2046
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 138 times.
381 if ( tempheader.new_version_devsig[0] ) zprint2("Developr Signoff by: %s\n", tempheader.new_version_devsig);
2047
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 138 times.
381 if ( tempheader.new_version_compilername[0] ) zprint2("Compiled with: %s, (ID: %d)\n", tempheader.new_version_compilername, tempheader.compilerid);
2048
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 138 times.
381 if ( tempheader.new_version_compilerversion[0] ) zprint2("Compiler Version: %s, (%d,%d,%d,%d)\n", tempheader.new_version_compilerversion,tempheader.compilerversionnumber_first,tempheader.compilerversionnumber_second,tempheader.compilerversionnumber_third,tempheader.compilerversionnumber_fourth);
2049
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 367 times.
381 if ( tempheader.product_name[0] ) zprint2("Project ID: %s\n", tempheader.product_name);
2050
2/2
✓ Branch 0 taken 243 times.
✓ Branch 1 taken 138 times.
381 if ( tempheader.new_version_id_date_day ) zprint2("Editor Built at date and time: %d-%d-%d at @ %s %s\n", tempheader.new_version_id_date_day, tempheader.new_version_id_date_month, tempheader.new_version_id_date_year, tempheader.build_timestamp, tempheader.build_timezone);
2051 381 zprint2("\n");
2052 381 }
2053
2054 695 int32_t readheader(PACKFILE *f, zquestheader *Header, byte printmetadata)
2055 {
2056 int32_t dummy;
2057 zquestheader tempheader;
2058 char dummybuf[80];
2059 byte temp_map_count;
2060 byte temp_midi_flags[MIDIFLAGS_SIZE];
2061 word version;
2062 char temp_pwd[30], temp_pwd2[30];
2063 int16_t temp_pwdkey;
2064 cvs_MD5Context ctx;
2065 695 memset(temp_midi_flags, 0, MIDIFLAGS_SIZE);
2066 695 memset(&tempheader, 0, sizeof(tempheader));
2067 695 memset(FFCore.quest_format, 0, sizeof(FFCore.quest_format));
2068
2069
2070
2071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 if(!pfread(tempheader.id_str,sizeof(tempheader.id_str),f)) // first read old header
2072 {
2073 Z_message("Unable to read header string\n");
2074 return qe_invalid;
2075 }
2076
2077 // check header
2078
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2079 {
2080
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
2081 {
2082 Z_message("Invalid header string: '%s' (was expecting '%s' or '%s')\n", tempheader.id_str, QH_IDSTR, QH_NEWIDSTR);
2083 return qe_invalid;
2084 }
2085 24 }
2086
2087 695 int32_t templatepath_len=0;
2088
2089 695 tempheader.external_zinfo = false;
2090 695 read_zinfo = false;
2091
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 if(!strcmp(tempheader.id_str,QH_IDSTR)) //pre-1.93 version
2092 {
2093 byte padding;
2094
2095
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f))
2096 {
2097 return qe_invalid;
2098 }
2099
2100
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.zelda_version,f))
2101 {
2102 return qe_invalid;
2103 }
2104
2105 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2106
2107
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version > ZELDA_VERSION)
2108 {
2109 return qe_version;
2110 }
2111
2112 24 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2113
2114
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(strcmp(tempheader.id_str,QH_IDSTR))
2115 {
2116 return qe_invalid;
2117 }
2118
2119
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(bad_version(tempheader.zelda_version))
2120 {
2121 return qe_obsolete;
2122 }
2123
2124
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&tempheader.internal,f))
2125 {
2126 return qe_invalid;
2127 }
2128
2129
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.quest_number,f))
2130 {
2131 return qe_invalid;
2132 }
2133
2134 24 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2135
2136
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(&quest_rules[0],2,f))
2137 {
2138 return qe_invalid;
2139 }
2140
2141
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&temp_map_count,f))
2142 {
2143 return qe_invalid;
2144 }
2145
2146 24 FFCore.quest_format[qMapCount] = temp_map_count;
2147
2148
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.old_str_count,f))
2149 {
2150 return qe_invalid;
2151 }
2152
2153
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2154 {
2155 return qe_invalid;
2156 }
2157
2158
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(temp_midi_flags,4,f))
2159 {
2160 return qe_invalid;
2161 }
2162
2163
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2164 {
2165 return qe_invalid;
2166 }
2167
2168
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(dummybuf,14,f))
2169 {
2170 return qe_invalid;
2171 }
2172
2173
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(&quest_rules[2],2,f))
2174 {
2175 return qe_invalid;
2176 }
2177
2178
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&dummybuf,f))
2179 {
2180 return qe_invalid;
2181 }
2182
2183
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.version,9,f))
2184 {
2185 return qe_invalid;
2186 }
2187
2188
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2189 {
2190 return qe_invalid;
2191 }
2192 // These fields are expected to end in null bytes!
2193 24 tempheader.title[sizeof(tempheader.title)-1] = 0;
2194
2195
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2196 {
2197 return qe_invalid;
2198 }
2199 24 tempheader.author[sizeof(tempheader.author)-1] = 0;
2200
2201
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&padding,f))
2202 {
2203 return qe_invalid;
2204 }
2205
2206
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_igetw(&temp_pwdkey,f))
2207 {
2208 return qe_invalid;
2209 }
2210
2211
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(temp_pwd,30,f))
2212 {
2213 return qe_invalid;
2214 }
2215
2216 24 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2217 24 cvs_MD5Init(&ctx);
2218 24 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2219 24 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2220
2221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24 times.
24 if(tempheader.zelda_version < 0x177) // lacks new header stuff...
2222 {
2223 //memset(tempheader.minver,0,20); // char minver[9], byte build, byte foo[10]
2224 // Not anymore...
2225 memset(tempheader.minver,0,17);
2226 tempheader.build=0;
2227 tempheader.use_keyfile=0;
2228 memset(tempheader.old_foo, 0, 9);
2229 }
2230 else
2231 {
2232
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(tempheader.minver,9,f))
2233 {
2234 return qe_invalid;
2235 }
2236
2237
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.build,f))
2238 {
2239 return qe_invalid;
2240 }
2241
2242 24 FFCore.quest_format[vBuild] = tempheader.build;
2243
2244
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!p_getc(&tempheader.use_keyfile,f))
2245 {
2246 return qe_invalid;
2247 }
2248
2249
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 if(!pfread(dummybuf,9,f))
2250 {
2251 return qe_invalid;
2252 }
2253 } // starting at minver
2254
2255
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
24 if(tempheader.zelda_version < 0x187) // lacks newer header stuff...
2256 {
2257 6 memset(&quest_rules[4],0,16); // word rules3..rules10
2258 6 }
2259 else
2260 {
2261
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!pfread(&quest_rules[4],16,f)) // read new header additions
2262 {
2263 return qe_invalid; // starting at rules3
2264 }
2265
2266
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
18 if(tempheader.zelda_version <= 0x190)
2267 {
2268 12 set_qr(qr_MEANPLACEDTRAPS,0);
2269 12 }
2270 }
2271 24 unpack_qrs();
2272
2273
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((tempheader.zelda_version < 0x192)||
2274
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<149)))
2275 {
2276 18 set_qr(qr_BRKNSHLDTILES,(get_qr(qr_BRKBLSHLDS_DEP)));
2277 18 set_bit(deprecated_rules,qr_BRKBLSHLDS_DEP,1);
2278 18 set_qr(qr_BRKBLSHLDS_DEP,1);
2279 18 }
2280
2281
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(tempheader.zelda_version >= 0x192) // lacks newer header stuff...
2282 {
2283 6 byte *mf=temp_midi_flags;
2284
2285
3/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2 times.
✓ Branch 3 taken 4 times.
6 if((tempheader.zelda_version == 0x192)&&(tempheader.build<178))
2286 {
2287 4 mf=(byte*)dummybuf;
2288 4 }
2289
2290
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(mf,32,f)) // read new header additions
2291 {
2292 return qe_invalid; // starting at foo2
2293 }
2294
2295
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(dummybuf,18,f)) // read new header additions
2296 {
2297 return qe_invalid; // starting at foo2
2298 }
2299 6 }
2300
2301
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((tempheader.zelda_version < 0x192)||
2302
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<145)))
2303 {
2304 18 memset(tempheader.templatepath,0,2048);
2305 18 }
2306 else
2307 {
2308
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 if(!pfread(tempheader.templatepath,280,f)) // read templatepath
2309 {
2310 return qe_invalid;
2311 }
2312 }
2313
2314
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
30 if((tempheader.zelda_version < 0x192)||
2315
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((tempheader.zelda_version == 0x192)&&(tempheader.build<186)))
2316 {
2317 24 tempheader.use_keyfile=0;
2318 24 }
2319 24 }
2320 else
2321 {
2322 //section id
2323
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_mgetl(&dummy,f))
2324 {
2325 return qe_invalid;
2326 }
2327
2328 //section version info
2329
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&version,f))
2330 {
2331 return qe_invalid;
2332 }
2333
2334 671 FFCore.quest_format[vHeader] = version;
2335
2336
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&dummy,f))
2337 {
2338 return qe_invalid;
2339 }
2340
2341 //section size
2342
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&dummy,f))
2343 {
2344 return qe_invalid;
2345 }
2346
2347 //finally... section data
2348
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&tempheader.zelda_version,f))
2349 {
2350 return qe_invalid;
2351 }
2352
2353 671 FFCore.quest_format[vZelda] = tempheader.zelda_version;
2354
2355 //do some quick checking...
2356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(tempheader.zelda_version > ZELDA_VERSION)
2357 {
2358 return qe_version;
2359 }
2360
2361
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(strcmp(tempheader.id_str,QH_NEWIDSTR))
2362 {
2363 return qe_invalid;
2364 }
2365
2366
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(bad_version(tempheader.zelda_version))
2367 {
2368 return qe_obsolete;
2369 }
2370
2371
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_getc(&tempheader.build,f))
2372 {
2373 return qe_invalid;
2374 }
2375
2376 671 FFCore.quest_format[vBuild] = tempheader.build;
2377
2378
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 612 times.
671 if(version<3)
2379 {
2380
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!pfread(temp_pwd,30,f))
2381 {
2382 return qe_invalid;
2383 }
2384
2385
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&temp_pwdkey,f))
2386 {
2387 return qe_invalid;
2388 }
2389
2390 59 get_questpwd(temp_pwd, temp_pwdkey, temp_pwd2);
2391 59 cvs_MD5Init(&ctx);
2392 59 cvs_MD5Update(&ctx, (const uint8_t*)temp_pwd2, (unsigned)strnlen(temp_pwd2, 30));
2393 59 cvs_MD5Final(tempheader.pwd_hash, &ctx);
2394 59 }
2395 else
2396 {
2397
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!pfread(tempheader.pwd_hash,sizeof(tempheader.pwd_hash),f))
2398 {
2399 return qe_invalid;
2400 }
2401 }
2402
2403
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&tempheader.internal,f))
2404 {
2405 return qe_invalid;
2406 }
2407
2408
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_getc(&tempheader.quest_number,f))
2409 {
2410 return qe_invalid;
2411 }
2412
2413 671 FFCore.quest_format[qQuestNumber] = tempheader.quest_number;
2414
2415 671 size_t versz = version < 8 ? 9 : 16;
2416
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!pfread(tempheader.version,versz,f))
2417 {
2418 return qe_invalid;
2419 }
2420
2421 //FFCore.quest_format[qQuestVersion] = tempheader.version;
2422 //needs to be copied as char[9] or stored as a s.str
2423
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!pfread(tempheader.minver,versz,f))
2424 {
2425 return qe_invalid;
2426 }
2427
2428 //FFCore.quest_format[qMinQuestVersion] = tempheader.minver;
2429
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!pfread(tempheader.title,sizeof(tempheader.title),f))
2430 {
2431 return qe_invalid;
2432 }
2433 671 tempheader.title[sizeof(tempheader.title)-1] = 0;
2434
2435
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!pfread(tempheader.author,sizeof(tempheader.author),f))
2436 {
2437 return qe_invalid;
2438 }
2439 671 tempheader.author[sizeof(tempheader.author)-1] = 0;
2440
2441
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_getc(&tempheader.use_keyfile,f))
2442 {
2443 return qe_invalid;
2444 }
2445
2446 /*
2447 if(!pfread(tempheader.data_flags,sizeof(tempheader.data_flags),f))
2448 {
2449 return qe_invalid;
2450 }
2451 */
2452
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_getc(&tempheader.data_flags[ZQ_TILES],f))
2453 {
2454 return qe_invalid;
2455 }
2456
2457
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!pfread(&dummybuf,4,f))
2458 {
2459 return qe_invalid;
2460 }
2461
2462
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_getc(&tempheader.data_flags[ZQ_CHEATS2],f))
2463 {
2464 return qe_invalid;
2465 }
2466
2467
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!pfread(dummybuf,14,f))
2468 {
2469 return qe_invalid;
2470 }
2471
2472 671 templatepath_len=sizeof(tempheader.templatepath);
2473
2474
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 59 times.
671 if(version==1)
2475 {
2476 59 templatepath_len=280;
2477 59 }
2478
2479
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!pfread(tempheader.templatepath,templatepath_len,f))
2480 {
2481 return qe_invalid;
2482 }
2483
2484
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_getc(&temp_map_count,f))
2485 {
2486 return qe_invalid;
2487 }
2488
2489
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 248 times.
671 if(version>=4)
2490 {
2491
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.version_major,f))
2492 {
2493 return qe_invalid;
2494 }
2495
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.version_minor,f))
2496 {
2497 return qe_invalid;
2498 }
2499
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.version_patch,f))
2500 {
2501 return qe_invalid;
2502 }
2503
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.new_version_id_fourth,f))
2504 {
2505 return qe_invalid;
2506 }
2507
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.new_version_id_alpha,f))
2508 {
2509 return qe_invalid;
2510 }
2511
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.new_version_id_beta,f))
2512 {
2513 return qe_invalid;
2514 }
2515
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.new_version_id_gamma,f))
2516 {
2517 return qe_invalid;
2518 }
2519
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.new_version_id_release,f))
2520 {
2521 return qe_invalid;
2522 }
2523
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetw(&tempheader.new_version_id_date_year,f))
2524 {
2525 return qe_invalid;
2526 }
2527
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&tempheader.new_version_id_date_month,f))
2528 {
2529 return qe_invalid;
2530 }
2531
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&tempheader.new_version_id_date_day,f))
2532 {
2533 return qe_invalid;
2534 }
2535
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&tempheader.new_version_id_date_hour,f))
2536 {
2537 return qe_invalid;
2538 }
2539
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&tempheader.new_version_id_date_minute,f))
2540 {
2541 return qe_invalid;
2542 }
2543
2544
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!pfread(tempheader.new_version_devsig,256,f))
2545 {
2546 return qe_invalid;
2547 }
2548
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!strcmp(tempheader.new_version_devsig, "Venrob"))
2549 strcpy(tempheader.new_version_devsig, "EmilyV99");
2550
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!pfread(tempheader.new_version_compilername,256,f))
2551 {
2552 return qe_invalid;
2553 }
2554
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!pfread(tempheader.new_version_compilerversion,256,f))
2555 {
2556 return qe_invalid;
2557 }
2558
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!pfread(tempheader.product_name,1024,f))
2559 {
2560 return qe_invalid;
2561 }
2562
2563
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&tempheader.compilerid,f))
2564 {
2565 return qe_invalid;
2566 }
2567
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.compilerversionnumber_first,f))
2568 {
2569 return qe_invalid;
2570 }
2571
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.compilerversionnumber_second,f))
2572 {
2573 return qe_invalid;
2574 }
2575
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.compilerversionnumber_third,f))
2576 {
2577 return qe_invalid;
2578 }
2579
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tempheader.compilerversionnumber_fourth,f))
2580 {
2581 return qe_invalid;
2582 }
2583
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetw(&tempheader.developerid,f))
2584 {
2585 return qe_invalid;
2586 }
2587
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!pfread(tempheader.made_in_module_name,1024,f))
2588 {
2589 return qe_invalid;
2590 }
2591
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!pfread(tempheader.build_datestamp,256,f))
2592 {
2593 return qe_invalid;
2594 }
2595
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!pfread(tempheader.build_timestamp,256,f))
2596 {
2597 return qe_invalid;
2598 }
2599 423 }
2600 else // <4
2601 {
2602 248 tempheader.version_major = 0;
2603 248 tempheader.version_minor = 0;
2604 248 tempheader.version_patch = 0;
2605 248 tempheader.new_version_id_fourth = 0;
2606 248 tempheader.new_version_id_alpha = 0;
2607 248 tempheader.new_version_id_beta = 0;
2608 248 tempheader.new_version_id_gamma = 0;
2609 248 tempheader.new_version_id_release = 0;
2610 248 tempheader.new_version_id_date_year = 0;
2611 248 tempheader.new_version_id_date_month = 0;
2612 248 tempheader.new_version_id_date_day = 0;
2613 248 tempheader.new_version_id_date_hour = 0;
2614 248 tempheader.new_version_id_date_minute = 0;
2615
2616 248 memset(tempheader.new_version_devsig, 0, 256);
2617 248 memset(tempheader.new_version_compilername, 0, 256);
2618 248 memset(tempheader.new_version_compilerversion, 0, 256);
2619 248 memset(tempheader.product_name, 0, 1024);
2620 248 strcpy(tempheader.product_name, "ZQuest Classic");
2621
2622 248 tempheader.compilerid = 0;
2623 248 tempheader.compilerversionnumber_first = 0;
2624 248 tempheader.compilerversionnumber_second = 0;
2625 248 tempheader.compilerversionnumber_third = 0;
2626 248 tempheader.compilerversionnumber_fourth = 0;
2627 248 tempheader.developerid = 0;
2628
2629 248 memset(tempheader.made_in_module_name, 0, 1024);
2630 248 memset(tempheader.build_datestamp, 0, 256);
2631 248 memset(tempheader.build_timestamp, 0, 256);
2632 }
2633
2634
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 248 times.
671 if ( version >= 5 )
2635 {
2636
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!pfread(tempheader.build_timezone,6,f))
2637 {
2638 return qe_invalid;
2639 }
2640 423 }
2641 else // < 5
2642 {
2643 248 memset(tempheader.build_timezone, 0, 6);
2644 }
2645
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 423 times.
671 if ( version >= 6 )
2646 {
2647 byte b;
2648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(!p_getc(&b,f))
2649 {
2650 return qe_invalid;
2651 }
2652 423 tempheader.external_zinfo = b?true:false;
2653 423 read_zinfo = true;
2654 423 }
2655
2656
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 248 times.
671 if(version >= 7)
2657 {
2658
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&(tempheader.new_version_is_nightly),f))
2659 {
2660 return qe_invalid;
2661 }
2662 423 }
2663 else
2664 {
2665 248 tempheader.new_version_is_nightly = false;
2666
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 248 times.
248 if(tempheader.zelda_version < 0x255)
2667 {
2668
2/5
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 189 times.
✗ Branch 4 not taken.
248 switch(tempheader.zelda_version)
2669 {
2670 case 0x254:
2671 tempheader.version_major = 2;
2672 tempheader.version_minor = 54;
2673 break;
2674 case 0x250:
2675
7/16
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✓ Branch 6 taken 28 times.
✗ Branch 7 not taken.
✓ Branch 8 taken 24 times.
✗ Branch 9 not taken.
✓ Branch 10 taken 6 times.
✓ Branch 11 taken 81 times.
✗ Branch 12 not taken.
✓ Branch 13 taken 16 times.
✓ Branch 14 taken 19 times.
✓ Branch 15 taken 15 times.
189 switch(tempheader.build)
2676 {
2677 case 19:
2678 tempheader.version_major = 2;
2679 tempheader.version_minor = 50;
2680 tempheader.new_version_id_gamma = 1;
2681 break;
2682 case 20:
2683 tempheader.version_major = 2;
2684 tempheader.version_minor = 50;
2685 tempheader.new_version_id_gamma = 2;
2686 break;
2687 case 21:
2688 tempheader.version_major = 2;
2689 tempheader.version_minor = 50;
2690 tempheader.new_version_id_gamma = 3;
2691 break;
2692 case 22:
2693 tempheader.version_major = 2;
2694 tempheader.version_minor = 50;
2695 tempheader.new_version_id_gamma = 4;
2696 break;
2697 case 23:
2698 tempheader.version_major = 2;
2699 tempheader.version_minor = 50;
2700 tempheader.new_version_id_gamma = 5;
2701 break;
2702 case 24:
2703 28 tempheader.version_major = 2;
2704 28 tempheader.version_minor = 50;
2705 28 tempheader.new_version_id_release = -1;
2706 28 break;
2707 case 25:
2708 tempheader.version_major = 2;
2709 tempheader.version_minor = 50;
2710 tempheader.version_patch = 1;
2711 tempheader.new_version_id_gamma = 1;
2712 break;
2713 case 26:
2714 24 tempheader.version_major = 2;
2715 24 tempheader.version_minor = 50;
2716 24 tempheader.version_patch = 1;
2717 24 tempheader.new_version_id_gamma = 2;
2718 24 break;
2719 case 27:
2720 tempheader.version_major = 2;
2721 tempheader.version_minor = 50;
2722 tempheader.version_patch = 1;
2723 tempheader.new_version_id_gamma = 3;
2724 break;
2725 case 28:
2726 6 tempheader.version_major = 2;
2727 6 tempheader.version_minor = 50;
2728 6 tempheader.version_patch = 1;
2729 6 tempheader.new_version_id_release = -1;
2730 6 break;
2731 case 29:
2732 81 tempheader.version_major = 2;
2733 81 tempheader.version_minor = 50;
2734 81 tempheader.version_patch = 2;
2735 81 tempheader.new_version_id_release = -1;
2736 81 break;
2737 case 30:
2738 tempheader.version_major = 2;
2739 tempheader.version_minor = 50;
2740 tempheader.version_patch = 3;
2741 tempheader.new_version_id_gamma = 1;
2742 break;
2743 case 31:
2744 16 tempheader.version_major = 2;
2745 16 tempheader.version_minor = 53;
2746 16 tempheader.new_version_id_gamma = -1;
2747 16 break;
2748 case 32:
2749 19 tempheader.version_major = 2;
2750 19 tempheader.version_minor = 53;
2751 19 tempheader.new_version_id_release = -1;
2752 19 break;
2753 case 33:
2754 15 tempheader.version_major = 2;
2755 15 tempheader.version_minor = 53;
2756 15 tempheader.version_patch = 1;
2757 15 break;
2758 }
2759 189 break;
2760
2761 case 0x211:
2762 tempheader.version_major = 2;
2763 tempheader.version_minor = 11;
2764 tempheader.new_version_id_beta = tempheader.build;
2765 break;
2766 case 0x210:
2767 59 tempheader.version_major = 2;
2768 59 tempheader.version_minor = 10;
2769 59 tempheader.new_version_id_beta = tempheader.build;
2770 59 break;
2771 }
2772 248 }
2773 }
2774
2775
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 566 times.
671 if (version>=9)
2776 {
2777 105 std::string version_string;
2778
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_getcstr(&version_string, f))
2779 {
2780 return qe_invalid;
2781 }
2782
2783 105 strncpy(tempheader.zelda_version_string, version_string.c_str(), sizeof(tempheader.zelda_version_string));
2784 105 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%s", version_string.c_str());
2785
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
105 }
2786 else
2787 {
2788 566 snprintf(tempheader.zelda_version_string, sizeof(tempheader.zelda_version_string), "%d.%d.%d", tempheader.version_major, tempheader.version_minor, tempheader.version_patch);
2789 }
2790
2791
3/4
✓ Branch 0 taken 662 times.
✓ Branch 1 taken 9 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 662 times.
671 if(printmetadata || __isZQuest)
2792 {
2793 9 print_quest_metadata(tempheader, loading_qst_name, loading_qst_num);
2794 9 }
2795 }
2796
2797 //{ Version Warning
2798 695 int32_t vercmp = tempheader.compareVer();
2799 695 int32_t astatecmp = compare(int32_t(tempheader.getAlphaState()), getAlphaState());
2800 695 int32_t avercmp = compare(tempheader.getAlphaVer(), 0);
2801
4/6
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✓ Branch 3 taken 590 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 105 times.
800 if(vercmp > 0 || (!vercmp &&
2802
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 (astatecmp > 0 || (!astatecmp &&
2803 105 avercmp > 0))))
2804 {
2805 bool r = true;
2806 if(loadquest_report)
2807 {
2808 enter_sys_pal();
2809 AlertDialog("Quest saved in newer version",
2810 "This quest was last saved in a newer version of ZQuest."
2811 " Attempting to load this quest may not work correctly; to"
2812 " avoid issues, try loading this quest in at least '" + std::string(tempheader.getVerStr()) + "'"
2813 "\n\nWould you like to continue loading anyway? (Not recommended)",
2814 [&](bool ret,bool)
2815 {
2816 r = ret;
2817 }).show();
2818 exit_sys_pal();
2819 }
2820 if(!r)
2821 return qe_silenterr;
2822 }
2823
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 else if(tempheader.compareDate() > 0)
2824 {
2825 bool r = true;
2826 if(loadquest_report)
2827 {
2828 enter_sys_pal();
2829 AlertDialog("Quest saved in newer build",
2830 fmt::format("This quest was last saved in a newer build of ZQuest, and may have"
2831 " issues loading in this build."
2832 "\n{}"
2833 "\n\nWould you like to continue loading anyway?",
2834 tempheader.getVerCmpStr()),
2835 [&](bool ret,bool)
2836 {
2837 r = ret;
2838 }).show();
2839 exit_sys_pal();
2840 }
2841 if(!r)
2842 return qe_silenterr;
2843 }
2844 //}
2845
2846 695 read_ext_zinfo = tempheader.external_zinfo;
2847
2848 695 memcpy(Header, &tempheader, sizeof(tempheader));
2849 695 map_count=temp_map_count;
2850 695 memcpy(midi_flags, temp_midi_flags, MIDIFLAGS_SIZE);
2851
2852 695 unpack_qrs();
2853
2854 695 return 0;
2855 695 }
2856
2857 692 int32_t readrules(PACKFILE *f, zquestheader *Header)
2858 {
2859
2/2
✓ Branch 0 taken 669 times.
✓ Branch 1 taken 23 times.
692 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_rules);
2860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 692 times.
692 if (should_skip)
2861 return 0;
2862
2863 int32_t dummy;
2864 zquestheader tempheader;
2865 692 word s_version=0;
2866 692 dword compatrule_version=0;
2867
2868 692 memcpy(&tempheader, Header, sizeof(tempheader));
2869
2870
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 671 times.
692 if(tempheader.zelda_version >= 0x193)
2871 {
2872 //section version info
2873
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_version,f))
2874 {
2875 return qe_invalid;
2876 }
2877
2878 671 FFCore.quest_format[vRules] = s_version;
2879
2880
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&dummy,f))
2881 {
2882 return qe_invalid;
2883 }
2884
2885
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 423 times.
671 if(s_version > 16)
2886 {
2887
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&compatrule_version,f))
2888 {
2889 return qe_invalid;
2890 }
2891 423 }
2892 671 FFCore.quest_format[vCompatRule] = compatrule_version;
2893
2894 //section size
2895
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&dummy,f))
2896 {
2897 return qe_invalid;
2898 }
2899
2900
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 423 times.
671 if ( s_version < 15 )
2901 {
2902 //finally... section data
2903
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 if(!pfread(quest_rules,QUESTRULES_SIZE,f))
2904 {
2905 return qe_invalid;
2906 }
2907 248 }
2908 else
2909 {
2910
2911
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!pfread(quest_rules,QUESTRULES_NEW_SIZE,f))
2912 {
2913 return qe_invalid;
2914 }
2915
2916 }
2917 671 }
2918
2919 //{ bunch of compat stuff
2920 692 memcpy(deprecated_rules, quest_rules, QUESTRULES_NEW_SIZE);
2921
2922 692 unpack_qrs();
2923
2924
2/2
✓ Branch 0 taken 610 times.
✓ Branch 1 taken 82 times.
692 if(s_version<2)
2925 {
2926 82 set_qr(14,0);
2927 82 set_qr(27,0);
2928 82 set_qr(28,0);
2929 82 set_qr(29,0);
2930 82 set_qr(30,0);
2931 82 set_qr(32,0);
2932 82 set_qr(36,0);
2933 82 set_qr(49,0);
2934 82 set_qr(50,0);
2935 82 set_qr(51,0);
2936 82 set_qr(68,0);
2937 82 set_qr(75,0);
2938 82 set_qr(76,0);
2939 82 set_qr(98,0);
2940 82 set_qr(110,0);
2941 82 set_qr(113,0);
2942 82 set_qr(116,0);
2943 82 set_qr(102,0);
2944 82 set_qr(132,0);
2945 82 }
2946
2947 //Now, do any updates...
2948
5/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 80 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
692 if((tempheader.zelda_version < 0x211)||((tempheader.zelda_version == 0x211)&&(tempheader.build<18)))
2949 {
2950 94 set_qr(qr_SMOOTHVERTICALSCROLLING,1);
2951 94 set_qr(qr_REPLACEOPENDOORS, 1);
2952 94 set_qr(qr_OLDLENSORDER, 1);
2953 94 set_qr(qr_NOFAIRYGUYFIRES, 1);
2954 94 set_qr(qr_TRIGGERSREPEAT, 1);
2955 94 }
2956
2957
5/6
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 671 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
708 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2958 {
2959 35 set_qr(qr_WALLFLIERS,1);
2960 35 }
2961
2962
5/6
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 671 times.
✓ Branch 4 taken 14 times.
✓ Branch 5 taken 14 times.
708 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<4)))
2963 {
2964 35 set_qr(qr_NOBOMBPALFLASH,1);
2965 35 }
2966
2967
5/6
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 21 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 671 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 18 times.
708 if((tempheader.zelda_version < 0x193)||((tempheader.zelda_version == 0x193)&&(tempheader.build<3)))
2968 {
2969 39 set_qr(qr_NOSCROLLCONTINUE,1);
2970 39 }
2971
2972
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 82 times.
712 if(tempheader.zelda_version <= 0x210)
2973 {
2974 82 set_qr(qr_ARROWCLIP,1);
2975 82 }
2976
2977
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 59 times.
688 if(tempheader.zelda_version == 0x210)
2978 {
2979 59 set_qr(qr_NOSCROLLCONTINUE, get_qr(qr_CMBCYCLELAYERS));
2980 59 set_qr(qr_CMBCYCLELAYERS, 0);
2981 59 set_qr(qr_CONT_SWORD_TRIGGERS, 1);
2982 59 }
2983
2984
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 82 times.
688 if(tempheader.zelda_version <= 0x210)
2985 {
2986 82 set_qr(qr_OLDSTYLEWARP,1);
2987 82 set_qr(qr_210_WARPRETURN,1);
2988 82 }
2989
2990 //might not be correct
2991
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 23 times.
688 if(tempheader.zelda_version < 0x210)
2992 {
2993 23 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP,1);
2994 23 set_qr(qr_OLDTRIBBLES_DEP,1);
2995 23 set_qr(qr_OLDHOOKSHOTGRAB,1);
2996 23 }
2997
2998
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 82 times.
688 if(tempheader.zelda_version < 0x211)
2999 {
3000 82 set_qr(qr_WRONG_BRANG_TRAIL_DIR,1);
3001 82 }
3002
3003
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 683 times.
✓ Branch 2 taken 17 times.
✓ Branch 3 taken 666 times.
688 if((tempheader.zelda_version == 0x192 && tempheader.build <= 163) || tempheader.zelda_version < 0x192)
3004 {
3005 22 set_qr(qr_192b163_WARP,1);
3006 22 }
3007
3008
2/2
✓ Branch 0 taken 629 times.
✓ Branch 1 taken 59 times.
688 if(tempheader.zelda_version == 0x210)
3009 {
3010 59 set_bit(deprecated_rules, qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3011 59 set_qr(qr_OLDTRIBBLES_DEP, get_qr(qr_DMGCOMBOPRI));
3012 59 set_qr(qr_DMGCOMBOPRI, 0);
3013 59 }
3014
3015
5/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 18 times.
688 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build<15))
3016 {
3017 94 set_qr(qr_OLDPICKUP,1);
3018 94 }
3019
3020
5/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 76 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 18 times.
712 if(tempheader.zelda_version < 0x211 || (tempheader.zelda_version == 0x211 && tempheader.build < 18))
3021 {
3022 94 set_qr(qr_NOSOLIDDAMAGECOMBOS, 1);
3023 94 set_qr(qr_ITEMPICKUPSETSBELOW, 1); // broke around build 400
3024 94 }
3025
3026
2/2
✓ Branch 0 taken 606 times.
✓ Branch 1 taken 82 times.
712 if(tempheader.zelda_version < 0x250) // version<0x250 checks for beta 18; build was set to 18 prematurely
3027 {
3028 82 set_qr(qr_HOOKSHOTDOWNBUG, 1);
3029 82 }
3030
3031
4/4
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 499 times.
✓ Branch 2 taken 161 times.
✓ Branch 3 taken 28 times.
688 if(tempheader.zelda_version == 0x250 && tempheader.build == 24) // Annoying...
3032 {
3033 28 set_qr(qr_PEAHATCLOCKVULN, 1);
3034 28 }
3035
3036
6/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 183 times.
688 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 22)) //22 is 2.50.0 RC4. Gotta set the door repair QR... -Dimi
3037 {
3038 94 set_qr(qr_OLD_DOORREPAIR, 1);
3039 94 }
3040
3041
6/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 76 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 18 times.
✓ Branch 5 taken 207 times.
688 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 20)) //20 is 2.50.0 RC1 and RC2 (cause it didn't get bumped). Okay I'm gonna be honest I have no idea if any 2.50 build was available before RC1, but gonna try and cover my ass here -Dimi
3042 {
3043 94 set_qr(qr_OLD_SECRETMONEY, 1);
3044 94 }
3045
3046
6/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 46 times.
✓ Branch 5 taken 155 times.
712 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 28)) //28 is 2.50.1 final. Potion bug might have been used, I dunno. -Dimi
3047 {
3048 146 set_qr(qr_OLD_POTION_OR_HC, 1);
3049 146 }
3050
3051
6/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 46 times.
✓ Branch 5 taken 155 times.
712 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<28))
3052 {
3053 146 set_qr(qr_OFFSCREENWEAPONS, 1);
3054 146 }
3055
3056 //Bombchu fix.
3057
2/2
✓ Branch 0 taken 523 times.
✓ Branch 1 taken 189 times.
712 if(tempheader.zelda_version == 0x250)
3058 {
3059
2/2
✓ Branch 0 taken 161 times.
✓ Branch 1 taken 28 times.
189 if ( tempheader.build == 24 ) //2.50.0
3060 {
3061 28 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3062 28 }
3063
2/2
✓ Branch 0 taken 183 times.
✓ Branch 1 taken 6 times.
189 if ( tempheader.build == 28 ) //2.50.1
3064 {
3065 6 set_qr(qr_BOMBCHUSUPERBOMB, 1);
3066 6 }
3067
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 81 times.
189 if ( tempheader.build == 29 ) //2.50.2
3068 {
3069 81 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3070 81 }
3071
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if ( tempheader.build == 30 ) //2.50.3RC1
3072 {
3073 set_qr(qr_BOMBCHUSUPERBOMB, 0);
3074 }
3075 189 }
3076
3077
6/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 100 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 161 times.
712 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3078 {
3079 // qr_OFFSETEWPNCOLLISIONFIX
3080 // All 'official' quests need this disabled.
3081 // All 2.10 and lower quests need this enabled to preseve compatability.
3082 // All 2.11 - 2.5.1 quests should have it set also, due to a bug in about half of all the betas.
3083
3084 //~Gleeok
3085 152 set_qr(qr_OFFSETEWPNCOLLISIONFIX, 1); //This has to be set!!!!
3086
3087 // Broke in build 695
3088
3/4
✓ Branch 0 taken 58 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 58 times.
152 if(tempheader.zelda_version>=0x211 && tempheader.build>=18)
3089 58 set_qr(qr_BROKENSTATUES, 1);
3090 140 }
3091
11/14
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 676 times.
✓ Branch 2 taken 671 times.
✓ Branch 3 taken 5 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
✓ Branch 6 taken 719 times.
✓ Branch 7 taken 5 times.
✓ Branch 8 taken 719 times.
✓ Branch 9 taken 5 times.
✓ Branch 10 taken 702 times.
✓ Branch 11 taken 22 times.
✗ Branch 12 not taken.
✗ Branch 13 not taken.
724 if (tempheader.zelda_version <= 0x190 || (tempheader.zelda_version == 0x192 && std::string(tempheader.title).starts_with("Zelda 3000\0")))
3092 {
3093 22 set_qr(qr_COPIED_SWIM_SPRITES, 1);
3094 22 }
3095
9/10
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 535 times.
✓ Branch 2 taken 520 times.
✓ Branch 3 taken 15 times.
✓ Branch 4 taken 438 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 423 times.
✓ Branch 7 taken 15 times.
✗ Branch 8 not taken.
✓ Branch 9 taken 423 times.
724 if ( (tempheader.zelda_version == 0x250 && tempheader.build < 33) || tempheader.zelda_version == 0x254 || tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3096 {
3097 286 set_qr(qr_OLD_SLASHNEXT_SECRETS, 1);
3098 286 }
3099
3100
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if ( (tempheader.zelda_version < 0x211) ) //2.10 water and ladder interaction
3101 {
3102 82 set_qr(qr_OLD_210_WATER, 1);
3103 82 }
3104
3105
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( (tempheader.zelda_version < 0x255 ) || (tempheader.zelda_version == 0x255 && tempheader.build < 51 ) ) //2.10 water and ladder interaction
3106 {
3107 271 set_qr(qr_STEP_IS_FLOAT,0);
3108 271 }
3109
3110
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if ( tempheader.zelda_version < 0x250 )
3111 {
3112 82 set_qr(qr_8WAY_SHOT_SFX, 1);
3113 82 }
3114
3115
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(s_version < 3)
3116 {
3117 82 set_qr(qr_HOLDNOSTOPMUSIC, 1);
3118 82 set_qr(qr_CAVEEXITNOSTOPMUSIC, 1);
3119 82 }
3120
3121
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(s_version<4)
3122 {
3123 82 set_qr(10,0);
3124 82 }
3125
3126
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(s_version<5)
3127 {
3128 82 set_qr(27,0);
3129 82 }
3130
3131
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(s_version<6)
3132 {
3133 82 set_qr(46,0);
3134 82 }
3135
3136
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(s_version<7) // January 2008
3137 {
3138 82 set_qr(qr_HEARTSREQUIREDFIX,0);
3139 82 set_qr(qr_PUSHBLOCKCSETFIX,1);
3140 82 }
3141
3142
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 612 times.
694 if(s_version<8)
3143 {
3144 82 set_qr(12, 0);
3145 82 }
3146 else
3147 {
3148 612 set_bit(deprecated_rules, 12, 0);
3149 }
3150
3151
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(s_version<9) // October 2008
3152 {
3153 82 set_qr(qr_NOROPE2FLASH_DEP,0);
3154 82 set_qr(qr_NOBUBBLEFLASH_DEP,0);
3155 82 set_qr(qr_GHINI2BLINK_DEP,0);
3156 82 set_qr(qr_PHANTOMGHINI2_DEP,0);
3157 82 }
3158
3159
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(s_version<10) // December 2008
3160 {
3161 82 set_qr(qr_NOCLOCKS_DEP,0);
3162 82 set_qr(qr_ALLOW10RUPEEDROPS_DEP,0);
3163 82 }
3164
3165
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(s_version<11) // April 2009
3166 {
3167 82 set_qr(qr_SLOWENEMYANIM_DEP,0);
3168 82 }
3169
3170 // This served no purpose.
3171 // if(s_version<12) // December 2009
3172 // {
3173 // set_qr(qr_BRKBLSHLDS_DEP,0);
3174 // set_qr(qr_OLDTRIBBLES_DEP,0);
3175 // }
3176
3177 //if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build < 24))
3178
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(s_version < 13)
3179 {
3180 82 set_qr(qr_SHOPCHEAT, 1);
3181 82 }
3182
3183 // Not entirely sure this is the best place for this...
3184 //2.50.2 bitmap offset fix
3185 694 memset(extra_rules, 0, EXTRARULES_SIZE);
3186
6/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 58 times.
✓ Branch 5 taken 131 times.
694 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<29))
3187 {
3188 140 set_er(er_BITMAPOFFSET, 1);
3189 140 set_qr(qr_BITMAPOFFSETFIX, 1);
3190 140 }
3191 //required because quest templates also used this bit, although
3192 //it never did anything, before. -Z
3193
2/2
✓ Branch 0 taken 505 times.
✓ Branch 1 taken 189 times.
694 if ( tempheader.zelda_version == 0x250 )
3194 {
3195
5/6
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 81 times.
✓ Branch 2 taken 108 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 16 times.
✓ Branch 5 taken 92 times.
189 if( tempheader.build == 29 || tempheader.build == 30 || tempheader.build == 31 )
3196 {
3197 97 set_er(er_BITMAPOFFSET, 0);
3198 97 set_qr(qr_BITMAPOFFSETFIX, 0);
3199 97 }
3200 189 }
3201
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 if ( tempheader.zelda_version == 0x254 )
3202 {
3203 set_er(er_BITMAPOFFSET, 0);
3204 set_qr(qr_BITMAPOFFSETFIX, 0);
3205 }
3206
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
694 if ( tempheader.zelda_version == 0x255 && tempheader.build < 42 ) //QR was added to 255 in this build.
3207 {
3208 set_er(er_BITMAPOFFSET, 0);
3209 set_qr(qr_BITMAPOFFSETFIX, 0);
3210 }
3211 //optimise fast drawing for older versions.
3212
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3213 {
3214 271 set_qr(qr_OLDSPRITEDRAWS, 1);
3215 271 }
3216 //Old eweapon->Parent (was added in 2.54, Alpha 19)
3217 //The change was made in build 43, but I'm setting this to < 42, because quests made in 42 would benefit from this change, and
3218 //older quests can set the rule by hand. We need a new qst.dat again.
3219
4/6
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 271 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 42) )
3220 {
3221 set_qr(qr_OLDEWPNPARENT, 1);
3222 }
3223
4/6
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 271 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3224 {
3225 set_qr(qr_OLDCREATEBITMAP_ARGS, 1);
3226 }
3227
4/6
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 423 times.
✓ Branch 3 taken 271 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version == 0x254 || (tempheader.zelda_version == 0x255 && tempheader.build < 45) )
3228 {
3229 set_qr(qr_OLDQUESTMISC, 1);
3230 }
3231
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if ( tempheader.zelda_version < 0x254 )
3232 {
3233 271 set_qr(qr_OLDCREATEBITMAP_ARGS, 0);
3234 271 set_qr(qr_OLDEWPNPARENT, 0);
3235 271 set_qr(qr_OLDQUESTMISC, 0);
3236 271 }
3237
3238 //item scripts continue to run
3239
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 44) )
3240 {
3241 271 set_qr(qr_ITEMSCRIPTSKEEPRUNNING, 0);
3242 271 set_qr(qr_SCRIPTSRUNINHEROSTEPFORWARD, 0);
3243 271 set_qr(qr_FIXSCRIPTSDURINGSCROLLING, 0);
3244 271 set_qr(qr_SCRIPTDRAWSINWARPS, 0);
3245 271 set_qr(qr_DYINGENEMYESDONTHURTHERO, 0);
3246 271 set_qr(qr_OUTOFBOUNDSENEMIES, 0);
3247 271 set_qr(qr_SPRITEXY_IS_FLOAT, 0);
3248 271 }
3249
3250
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3251 {
3252 271 set_qr(qr_CLEARINITDONSCRIPTCHANGE, 1);
3253 271 }
3254
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 46) )
3255 {
3256 271 set_qr(qr_TRACESCRIPTIDS, 0);
3257 271 set_qr(qr_SCRIPT_FRIENDLY_ENEMY_TYPES, 1);
3258 271 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL, 1);
3259 271 set_qr(qr_PARSER_250DIVISION,1);
3260 271 set_qr(qr_PARSER_BOOL_TRUE_DECIMAL,1);
3261 271 set_qr(qr_PARSER_TRUE_INT_SIZE,0);
3262 271 set_qr(qr_PARSER_FORCE_INLINE,0);
3263 271 set_qr(qr_PARSER_BINARY_32BIT,0);
3264
2/2
✓ Branch 0 taken 264 times.
✓ Branch 1 taken 7 times.
271 if ( get_qr(qr_SELECTAWPN) )
3265 {
3266 7 set_qr(qr_NO_L_R_BUTTON_INVENTORY_SWAP,1);
3267 //In < 2.55a27, if you had an A+B subscreen, L and R didn't shift through inventory.
3268 //Now they **do**, unless you disable that behaviour.
3269 //For the sake of compatibility, old quests with the A+B subscreen rule enabed
3270 //now enable the disable L/R item swap on load.
3271 7 }
3272
3273 271 }
3274
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3275 {
3276 //Compatibility: Setting the hero's action to rafting was previously disallowed, though legal for scripts to attempt.
3277 271 set_qr(qr_DISALLOW_SETTING_RAFTING, 1);
3278 //Compatibility: The calculation for when to loop an animation did not factor in ASkipY correctly, resulting in
3279 //animations ending earlier than they should.
3280 271 set_qr(qr_BROKEN_ASKIP_Y_FRAMES, 1);
3281 //Enemies would ignore solidity on the top half of combos
3282 271 set_qr(qr_ENEMY_BROKEN_TOP_HALF_SOLIDITY, 1);
3283 //Ceiling collison was a bit wonky, including hitting your head before you are near the ceiling or clipping into it slightly.
3284 271 set_qr(qr_OLD_SIDEVIEW_CEILING_COLLISON, 1);
3285 //If an itemdata had a 'frames' of 0, items created of that data would ignore all changes to 'frames'
3286 271 set_qr(qr_0AFRAME_ITEMS_IGNORE_AFRAME_CHANGES, 1);
3287 //Collision used some odd calculations before, and enemies could not be hit back into the top row or left column
3288 271 set_qr(qr_OLD_ENEMY_KNOCKBACK_COLLISION, 1);
3289 271 }
3290
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if ( tempheader.zelda_version < 0x255 )
3291 {
3292 271 set_qr(qr_NOFFCWAITDRAW, 1);
3293 271 set_qr(qr_NOITEMWAITDRAW, 1);
3294 271 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3295 271 set_qr(qr_OLD_INIT_SCRIPT_TIMING, 1);
3296 //set_qr(qr_DO_NOT_DEALLOCATE_INIT_AND_SAVELOAD_ARRAYS, 1);
3297 271 }
3298
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 48 ) )
3299 {
3300 271 set_qr(qr_SETENEMYWEAPONSPRITESONWPNCHANGE, 1);
3301 271 }
3302
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if( tempheader.zelda_version < 0x255 || ( tempheader.zelda_version == 0x255 && tempheader.build < 52 ) )
3303 {
3304 271 set_qr(qr_OLD_PRINTF_ARGS, 1);
3305 271 }
3306
3307
3308
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 54) )
3309 {
3310 271 set_qr(qr_BROKEN_RING_POWER, 1);
3311 271 }
3312
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 56) )
3313 {
3314 271 set_qr(qr_NO_OVERWORLD_MAP_CHARTING, 1);
3315 271 }
3316
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 57) )
3317 {
3318 271 set_qr(qr_DUNGEONS_USE_CLASSIC_CHARTING, 1);
3319 271 }
3320
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 58) )
3321 {
3322 //Rule used to be 'qr_SETXYBUTTONITEMS', now split.
3323
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(get_qr(qr_SET_XBUTTON_ITEMS))
3324 set_qr(qr_SET_YBUTTON_ITEMS,1);
3325 271 }
3326
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 59) )
3327 {
3328 271 set_qr(qr_ALLOW_EDITING_COMBO_0,1);
3329 271 }
3330
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 60) )
3331 {
3332 271 set_qr(qr_OLD_CHEST_COLLISION,1);
3333 271 }
3334
3335
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if ( tempheader.zelda_version < 0x254 )
3336 {
3337 271 set_qr(qr_250WRITEEDEFSCRIPT, 1);
3338 271 }
3339 //Sideview spikes in 2.50.0
3340
6/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 52 times.
✓ Branch 5 taken 137 times.
694 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<27)) //2.50.1RC3
3341 {
3342 134 set_qr(qr_OLDSIDEVIEWSPIKES, 1);
3343 134 }
3344 //more 2.50 fixes -Z
3345
6/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 189 times.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 139 times.
✓ Branch 5 taken 50 times.
694 if(tempheader.zelda_version < 0x250 || (tempheader.zelda_version == 0x250 && tempheader.build<31))
3346 {
3347 221 set_qr(qr_MELEEMAGICCOST, 0);
3348 221 set_qr(qr_GANONINTRO, 0); //This will get flipped later on in the compatrule 11 check. That's why it's turning it off.
3349 221 set_qr(qr_OLDMIRRORCOMBOS, 1);
3350 221 set_qr(qr_BROKENBOOKCOST, 1);
3351 221 set_qr(qr_BROKENCHARINTDRAWING, 1);
3352
3353 221 }
3354
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
694 if(tempheader.zelda_version == 0x254 && tempheader.build<41)
3355 {
3356 //set_qr(qr_MELEEMAGICCOST, get_er(er_MAGICCOSTSWORD));
3357 set_qr(qr_MELEEMAGICCOST, 1);
3358 }
3359
3360
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 23 times.
694 if(tempheader.zelda_version < 0x193)
3361 {
3362 23 set_qr(qr_SHORTDGNWALK, 1);
3363 23 }
3364
3365
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(tempheader.zelda_version < 0x255)
3366 {
3367 271 set_qr(qr_OLDINFMAGIC, 1);
3368 271 }
3369
3370
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if((tempheader.zelda_version < 0x250)) //2.10 and earlier allowed the triforce to Warp Player out of Item Cellars in Dungeons. -Z (15th March, 2019 )
3371 {
3372 82 set_qr(qr_SIDEVIEWTRIFORCECELLAR,1);
3373 82 }
3374
3375
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 47) )
3376 {
3377 271 set_qr(qr_OLD_F6,1);
3378 271 }
3379
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 49) )
3380 {
3381 271 set_qr(qr_NO_OVERWRITING_HOPPING,1);
3382 271 }
3383
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 50) )
3384 {
3385 271 set_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT,1);
3386 271 }
3387
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
694 if ( tempheader.zelda_version < 0x255 || (tempheader.zelda_version == 0x255 && tempheader.build < 53) )
3388 {
3389 271 set_qr(qr_BROKEN_OVERWORLD_MINIMAP,1);
3390 271 }
3391 //}
3392
3393
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 1) //Enemies->Secret only affects flag 16-31
3394 271 set_qr(qr_ENEMIES_SECRET_ONLY_16_31,1);
3395
3396
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 2) //Old CSet2 Handling
3397 271 set_qr(qr_OLDCS2,1);
3398
3399
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 3) //Hardcoded Shadow/Spawn/Death anim frames
3400 271 set_qr(qr_HARDCODED_ENEMY_ANIMS,1);
3401
3402
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 4) //Hardcoded Shadow/Spawn/Death anim frames
3403 271 set_qr(qr_OLD_ITEMDATA_SCRIPT_TIMING,1);
3404
3405
4/4
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 423 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 189 times.
694 if(compatrule_version < 5 && tempheader.zelda_version >= 0x250) //Hardcoded Shadow/Spawn/Death anim frames
3406 189 set_qr(qr_NO_LANMOLA_RINGLEADER,1);
3407
3408
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 6) //Step->Secret (Temp) only affects flag 16-31
3409 271 set_qr(qr_STEPTEMP_SECRET_ONLY_16_31,1);
3410
3411
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 7) //'Hit All Triggers->Perm Secret' doesn't trigger temp secrets
3412 271 set_qr(qr_ALLTRIG_PERMSEC_NO_TEMP,1);
3413
3414
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 8) //Hardcoded LItem/Bomb/Clock/Magic Tile Mods
3415 271 set_qr(qr_HARDCODED_LITEM_LTMS,1);
3416
3417
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 9)
3418 {
3419 //Hardcoded BS Patras
3420 271 set_qr(qr_HARDCODED_BS_PATRA,1);
3421 //Hardcoded Patra Inner Eye offsets
3422 271 set_qr(qr_PATRAS_USE_HARDCODED_OFFSETS,1);
3423 //Broken 'Big enemy' animation style
3424 271 set_qr(qr_BROKEN_BIG_ENEMY_ANIMATION,1);
3425 //Broken Attribute 31/32
3426 271 set_qr(qr_BROKEN_ATTRIBUTE_31_32,1);
3427 271 }
3428
3429
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 10) //Shared candle use limits
3430 271 set_qr(qr_CANDLES_SHARED_LIMIT,1);
3431
3432
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 11) //No cross-screen return points
3433 271 set_qr(qr_OLD_RESPAWN_POINTS,1);
3434
3435
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 12)
3436 {
3437 //Old fire trail duration
3438 271 set_qr(qr_OLD_FLAMETRAIL_DURATION,1);
3439 //Old Intro String in Ganon Room Behavior
3440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 271 times.
271 if(get_qr(qr_GANONINTRO)) set_qr(qr_GANONINTRO,0);
3441 271 else set_qr(qr_GANONINTRO,1);
3442 271 }
3443
3444
3/4
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 423 times.
✓ Branch 2 taken 271 times.
✗ Branch 3 not taken.
694 if(compatrule_version < 13 && tempheader.zelda_version >= 0x255) //ANone doesn't reset to originaltile
3445 set_qr(qr_ANONE_NOANIM,1);
3446
3447
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 14) //Old Bridge Combo Behavior
3448 271 set_qr(qr_OLD_BRIDGE_COMBOS,1);
3449
3450
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 15) //Broken Z3 Animation
3451 271 set_qr(qr_BROKEN_Z3_ANIMATION,1);
3452
3453
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 16) //Old Enemy Tile Behavior with Animation (None) Enemies
3454 271 set_qr(qr_OLD_TILE_INITIALIZATION,1);
3455
3456
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 17)
3457 {
3458 //Old Quake/DrawYOffset behavior
3459 //set_qr(qr_OLD_DRAWOFFSET,1);
3460 //I'm leaving this commented cause I doubt it'll break anything and I think the bugfix might be appreciated in older versions.
3461 //On the offchance that it *does* break old quests, fixing it is as simple as uncommenting the set_bit above.
3462 271 }
3463
3464
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 18)
3465 {
3466 //Broken DrawScreen Derivative Functions
3467 271 set_qr(qr_BROKEN_DRAWSCREEN_FUNCTIONS,1);
3468 //Scrolling Cancels Charge
3469 271 set_qr(qr_SCROLLING_KILLS_CHARGE,1);
3470 271 }
3471
3472
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 19) //Broken Enemy Item Carrying with Large Enemies
3473 271 set_qr(qr_BROKEN_ITEM_CARRYING,1);
3474
3475
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 20)
3476 271 set_qr(qr_CUSTOMWEAPON_IGNORE_COST,1);
3477
3478
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 21)
3479 {
3480 271 set_qr(qr_LEEVERS_DONT_OBEY_STUN,1);
3481 271 set_qr(qr_GANON_CANT_SPAWN_ON_CONTINUE,1);
3482 271 set_qr(qr_WIZZROBES_DONT_OBEY_STUN,1);
3483 271 set_qr(qr_OLD_BUG_NET,1);
3484 271 set_qr(qr_MANHANDLA_BLOCK_SFX,1);
3485 271 }
3486
3487
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 22)
3488 271 set_qr(qr_BROKEN_KEEPOLD_FLAG,1);
3489
3490
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 23)
3491 271 set_qr(qr_OLD_HALF_MAGIC,1);
3492
3493
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 24)
3494 {
3495 271 set_qr(qr_WARPS_RESTART_DMAPSCRIPT,1);
3496 271 set_qr(qr_DMAP_0_CONTINUE_BUG,1);
3497 271 }
3498
3499
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 25)
3500 {
3501
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 271 times.
271 if (get_qr(qr_OLD_FAIRY_LIMIT)) set_qr(qr_OLD_FAIRY_LIMIT,0);
3502 271 else set_qr(qr_OLD_FAIRY_LIMIT,1);
3503 271 set_qr(qr_OLD_SCRIPTED_KNOCKBACK,1);
3504 271 }
3505
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 26)
3506 {
3507 271 set_qr(qr_OLD_KEESE_Z_AXIS,1);
3508 271 set_qr(qr_POLVIRE_NO_SHADOW,1);
3509 271 set_qr(qr_SUBSCR_OLD_SELECTOR,1);
3510 271 }
3511
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if(compatrule_version < 27) //Noticed some junk data in the QR array...
3512 {
3513
2/2
✓ Branch 0 taken 81571 times.
✓ Branch 1 taken 271 times.
81842 for(auto q = qr_POLVIRE_NO_SHADOW+1; q < qr_PARSER_250DIVISION; ++q)
3514 81571 set_qr(q,0);
3515
2/2
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 271 times.
1084 for(auto q = qr_COMBODATA_INITD_MULT_TENK+1; q < qr_MAX; ++q)
3516 813 set_qr(q,0);
3517 //This should nuke any remaining junk data... not sure if it affected anything previous. -Em
3518 271 }
3519
2/2
✓ Branch 0 taken 418 times.
✓ Branch 1 taken 276 times.
694 if(compatrule_version < 28)
3520 276 set_qr(qr_SUBSCR_BACKWARDS_ID_ORDER,1);
3521
2/2
✓ Branch 0 taken 418 times.
✓ Branch 1 taken 276 times.
694 if(compatrule_version < 29)
3522 276 set_qr(qr_OLD_LOCKBLOCK_COLLISION,1);
3523
2/2
✓ Branch 0 taken 418 times.
✓ Branch 1 taken 276 times.
694 if(compatrule_version < 30)
3524 {
3525 276 set_qr(qr_DECO_2_YOFFSET,1);
3526 276 set_qr(qr_SCREENSTATE_80s_BUG,1);
3527 276 }
3528
2/2
✓ Branch 0 taken 418 times.
✓ Branch 1 taken 276 times.
694 if(compatrule_version < 31)
3529 {
3530 276 set_qr(qr_GOHMA_UNDAMAGED_BUG,1);
3531 276 set_qr(qr_FFCPRELOAD_BUGGED_LOAD,1);
3532 276 }
3533
2/2
✓ Branch 0 taken 418 times.
✓ Branch 1 taken 276 times.
694 if(compatrule_version < 32)
3534 276 set_qr(qr_BROKEN_GETPIXEL_VALUE,1);
3535
2/2
✓ Branch 0 taken 418 times.
✓ Branch 1 taken 276 times.
694 if(compatrule_version < 33)
3536 276 set_qr(qr_NO_LIFT_SPRITE,1);
3537
2/2
✓ Branch 0 taken 418 times.
✓ Branch 1 taken 276 times.
694 if(compatrule_version < 34)
3538 {
3539 276 set_qr(qr_OLD_SIDEVIEW_LANDING_CODE,1);
3540 276 set_qr(qr_OLD_FFC_SPEED_CAP,1);
3541 276 set_qr(qr_OLD_FFC_FUNCTIONALITY,1);
3542 276 set_qr(qr_OLD_WIZZROBE_SUBMERGING,1);
3543 276 }
3544
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 278 times.
694 if(compatrule_version < 35)
3545 {
3546 278 set_qr(qr_ZS_NO_NEG_ARRAY,1);
3547 278 set_qr(qr_BROKEN_INPUT_DOWN_STATE,1);
3548 278 }
3549
2/2
✓ Branch 0 taken 416 times.
✓ Branch 1 taken 278 times.
694 if(compatrule_version < 36)
3550 278 set_qr(qr_OLD_SHALLOW_SFX,1);
3551
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 282 times.
694 if(compatrule_version < 37)
3552 282 set_qr(qr_SPARKLES_INHERIT_PROPERTIES,1);
3553
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 282 times.
694 if(compatrule_version < 38)
3554 282 set_qr(qr_BUGGED_LAYERED_FLAGS,1);
3555
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 282 times.
694 if(compatrule_version < 39)
3556 282 set_qr(qr_HARDCODED_FFC_BUSH_DROPS,1);
3557
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 282 times.
694 if(compatrule_version < 40)
3558 282 set_qr(qr_MOVINGBLOCK_FAKE_SOLID,1);
3559
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 284 times.
694 if(compatrule_version < 41)
3560 284 set_qr(qr_BROKENHITBY,1);
3561
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 284 times.
694 if(compatrule_version < 42)
3562 284 set_qr(qr_BROKEN_MOVING_BOMBS,1);
3563
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 284 times.
694 if(compatrule_version < 43)
3564 284 set_qr(qr_OLD_BOMB_HITBOXES,1);
3565
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 284 times.
694 if(compatrule_version < 44)
3566 284 set_qr(qr_SCROLLWARP_NO_RESET_FRAME,1);
3567
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 284 times.
694 if(compatrule_version < 45)
3568 284 set_qr(qr_ENEMIES_DONT_SCRIPT_FIRST_FRAME,1);
3569
2/2
✓ Branch 0 taken 410 times.
✓ Branch 1 taken 284 times.
694 if(compatrule_version < 46)
3570 284 set_qr(qr_BROKEN_RAFT_SCROLL,1);
3571
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 47)
3572 {
3573 289 set_qr(qr_SENSITIVE_SOLID_DAMAGE,1);
3574 289 set_qr(qr_OLD_CONVEYOR_COLLISION,1);
3575 289 }
3576
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 48)
3577 289 set_qr(qr_OLD_GUY_HANDLING,1);
3578
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 49)
3579 289 set_qr(qr_FAIRY_FLAG_COMPAT,1);
3580
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 50)
3581 289 set_qr(qr_OLD_LENS_LAYEREFFECT,1);
3582
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 51)
3583 289 set_qr(qr_PUSHBLOCK_SPRITE_LAYER,1);
3584
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if (compatrule_version < 52)
3585 289 set_qr(qr_OLD_SCRIPT_VOLUME, 1);
3586
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 53)
3587 {
3588 289 set_qr(qr_OLD_SUBSCR,1);
3589 289 set_qr(qr_ITM_0_INVIS_ON_BTNS,1);
3590 289 set_qr(qr_OLD_GAUGE_TILE_LAYOUT,1);
3591 289 }
3592
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 54)
3593 289 set_qr(qr_WALKTHROUGHWALL_NO_DOORSTATE,1);
3594
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 55)
3595 289 set_qr(qr_SPOTLIGHT_IGNR_SOLIDOBJ,1);
3596
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 56)
3597 289 set_qr(qr_BROKEN_LIGHTBEAM_HITBOX,1);
3598
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 57)
3599 289 set_qr(qr_BROKEN_SWORD_SPIN_TRIGGERS,1);
3600
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 58)
3601 289 set_qr(qr_OLD_DMAP_INTRO_STRINGS,1);
3602
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 59)
3603 289 set_qr(qr_SCRIPT_CONTHP_IS_HEARTS,1);
3604
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 60)
3605 289 set_qr(qr_SEPARATE_BOMBABLE_TAPPING_SFX,1);
3606
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 61)
3607 289 set_qr(qr_BROKEN_BOMB_AMMO_COSTS,1);
3608
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 62)
3609 289 set_qr(qr_OLD_BROKEN_WARPEX_MUSIC,1);
3610
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 63)
3611 {
3612 289 set_qr(qr_BROKEN_LIFTSWIM,1);
3613 289 set_qr(qr_BROKEN_GENERIC_PUSHBLOCK_LOCKING,1);
3614 289 }
3615
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 289 times.
694 if(compatrule_version < 64)
3616 289 set_qr(qr_BROKEN_FLAME_ARROW_REFLECTING,1);
3617
2/2
✓ Branch 0 taken 381 times.
✓ Branch 1 taken 313 times.
694 if(compatrule_version < 65)
3618 313 set_qr(qr_BROKEN_SIDEVIEW_SPRITE_JUMP,1);
3619
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 589 times.
694 if(compatrule_version < 66)
3620 589 set_qr(qr_NEWDARK_TRANS_STACKING,1);
3621
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 589 times.
694 if(compatrule_version < 67)
3622 589 set_qr(qr_OLD_HERO_WARP_RETSQUARE,1);
3623
2/2
✓ Branch 0 taken 38 times.
✓ Branch 1 taken 656 times.
694 if(compatrule_version < 68)
3624 656 set_qr(qr_SCRIPTS_6_BIT_COLOR,1);
3625
3626 694 set_qr(qr_ANIMATECUSTOMWEAPONS,0);
3627
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 271 times.
694 if (s_version < 16)
3628 271 set_qr(qr_BROKEN_HORIZONTAL_WEAPON_ANIM,1);
3629
3630 694 memcpy(Header, &tempheader, sizeof(tempheader));
3631
3632 694 return 0;
3633 694 }
3634
3635 5822376 void init_msgstr(MsgStr *str)
3636 {
3637 5822376 str->s = "";
3638 5822376 str->s.shrink_to_fit();
3639 5822376 str->nextstring=0;
3640 5822376 str->tile=0;
3641 5822376 str->cset=0;
3642 5822376 str->trans=false;
3643 5822376 str->font=font_zfont;
3644 5822376 str->y=32;
3645 5822376 str->sfx=18;
3646 5822376 str->listpos=0;
3647 5822376 str->x=24;
3648 5822376 str->w=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 24*8 : 26*8;
3649 5822376 str->h=get_qr(qr_STRING_FRAME_OLD_WIDTH_HEIGHT)!=0 ? 3*8 : 5*8;
3650 5822376 str->hspace=0;
3651 5822376 str->vspace=0;
3652 5822376 str->stringflags=0;
3653 5822376 str->margins[up] = 8;
3654 5822376 str->margins[down] = 0;
3655 5822376 str->margins[left] = 8;
3656 5822376 str->margins[right] = 8;
3657 5822376 str->portrait_tile = 0;
3658 5822376 str->portrait_cset = 0;
3659 5822376 str->portrait_x = 0;
3660 5822376 str->portrait_y = 0;
3661 5822376 str->portrait_tw = 1;
3662 5822376 str->portrait_th = 1;
3663 5822376 str->shadow_type = 0;
3664 5822376 str->shadow_color = 0;
3665 5822376 str->drawlayer = 6;
3666 5822376 }
3667
3668 694 void init_msgstrings(int32_t start, int32_t end)
3669 {
3670
2/4
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 694 times.
694 if(end <= start || end-start > msg_strings_size)
3671 return;
3672
3673
2/2
✓ Branch 0 taken 5685248 times.
✓ Branch 1 taken 694 times.
5685942 for(int32_t i=start; i<end; i++)
3674 {
3675 5685248 init_msgstr(&MsgStrings[i]);
3676 5685248 MsgStrings[i].listpos=i;
3677 5685248 }
3678
3679
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 if(start==0)
3680 {
3681 694 MsgStrings[0].s = "(None)";
3682 694 MsgStrings[0].listpos = 0;
3683 694 }
3684 694 }
3685
3686 695 int32_t readstrings(PACKFILE *f, zquestheader *Header)
3687 {
3688
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_strings);
3689
3690 695 MsgStr tempMsgString;
3691
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 init_msgstr(&tempMsgString);
3692
3693 695 word temp_msg_count=0;
3694 word temp_expansion[16];
3695 695 memset(temp_expansion, 0, 16*sizeof(word));
3696 695 char buf[8193] = {0};
3697
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 if(Header->zelda_version < 0x193)
3698 {
3699 byte tempbyte;
3700 24 int32_t strings_to_read=0;
3701
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3702
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3703
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
3704
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<31)))
3705 {
3706 18 strings_to_read=128;
3707 18 temp_msg_count=Header->old_str_count;
3708
3709 // Some sort of string count corruption seems to be common in old quests
3710
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(temp_msg_count>128)
3711 {
3712 temp_msg_count=128;
3713 }
3714 18 }
3715
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 else if((Header->zelda_version == 0x192)&&(Header->build<140))
3716 {
3717 strings_to_read=255;
3718 temp_msg_count=Header->old_str_count;
3719 }
3720 else
3721 {
3722
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if(!p_igetw(&temp_msg_count,f))
3723 {
3724 return qe_invalid;
3725 }
3726
3727 6 strings_to_read=temp_msg_count;
3728
3729
3/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 1 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
6 if (!should_skip && temp_msg_count >= msg_strings_size)
3730 {
3731 Z_message("Reallocating string buffer...\n");
3732
3733 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3734 // return qe_nomem;
3735
3736 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3737 delete[] MsgStrings;
3738 MsgStrings = new MsgStr[MAXMSGS];
3739 msg_strings_size = MAXMSGS;
3740 for(auto q = 0; q < msg_strings_size; ++q)
3741 {
3742 MsgStrings[q].clear();
3743 }
3744 }
3745 }
3746
3747 //reset the message strings
3748
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 1 times.
24 if (!should_skip)
3749
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 init_msgstrings(0,msg_strings_size);
3750
3751
2/2
✓ Branch 0 taken 2550 times.
✓ Branch 1 taken 24 times.
2574 for(int32_t x=0; x<strings_to_read; x++)
3752 {
3753
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 init_msgstr(&tempMsgString);
3754 2550 tempMsgString.listpos = x;
3755
3756
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!pfread(buf,73,f))
3757 {
3758 return qe_invalid;
3759 }
3760
3761 2550 buf[74] = '\0';
3762
1/2
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
2550 tempMsgString.s = buf;
3763
3764
2/4
✓ Branch 0 taken 2550 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2550 times.
✗ Branch 3 not taken.
2550 if(!p_getc(&tempbyte,f))
3765 {
3766 return qe_invalid;
3767 }
3768
3769
3/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 2304 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 246 times.
2796 if((Header->zelda_version < 0x192)||
3770
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 ((Header->zelda_version == 0x192)&&(Header->build<148)))
3771 {
3772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2304 times.
2304 tempMsgString.nextstring=tempbyte?x+1:0;
3773
3774
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3775 {
3776 return qe_invalid;
3777 }
3778
3779
2/4
✓ Branch 0 taken 2304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2304 times.
✗ Branch 3 not taken.
2304 if(!p_getc(&tempbyte,f))
3780 {
3781 return qe_invalid;
3782 }
3783 2304 }
3784 else
3785 {
3786
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!p_igetw(&tempMsgString.nextstring,f))
3787 {
3788 return qe_invalid;
3789 }
3790
3791
2/4
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 246 times.
✗ Branch 3 not taken.
246 if(!pfread(temp_expansion,32,f))
3792 {
3793 return qe_invalid;
3794 }
3795 }
3796
3797
2/2
✓ Branch 0 taken 2549 times.
✓ Branch 1 taken 1 times.
2550 if (!should_skip)
3798
1/2
✓ Branch 0 taken 2549 times.
✗ Branch 1 not taken.
2549 MsgStrings[x] = tempMsgString;
3799 2550 }
3800 24 }
3801 else
3802 {
3803 int32_t dummy_int;
3804 word s_version;
3805 word s_cversion;
3806
3807 //section version info
3808
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&s_version,f))
3809 {
3810 return qe_invalid;
3811 }
3812
3813 671 FFCore.quest_format[vStrings] = s_version;
3814
3815
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&s_cversion,f))
3816 {
3817 return qe_invalid;
3818 }
3819
3820 //section size
3821
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetl(&dummy_int,f))
3822 {
3823 return qe_invalid;
3824 }
3825
3826 //finally... section data
3827
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&temp_msg_count,f))
3828 {
3829 return qe_invalid;
3830 }
3831
3832
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(temp_msg_count >= msg_strings_size)
3833 {
3834 Z_message("Reallocating string buffer...\n");
3835
3836 // if((MsgStrings=(MsgStr*)_al_sane_realloc(MsgStrings,sizeof(MsgStr)*MAXMSGS))==NULL)
3837 // return qe_nomem;
3838 delete[] MsgStrings;
3839 MsgStrings = new MsgStr[MAXMSGS];
3840 msg_strings_size = MAXMSGS;
3841 for(auto q = 0; q < msg_strings_size; ++q)
3842 {
3843 MsgStrings[q].clear();
3844 }
3845 //memset(MsgStrings, 0, sizeof(MsgStr)*MAXMSGS);
3846 }
3847
3848 //reset the message strings
3849
2/2
✓ Branch 0 taken 248 times.
✓ Branch 1 taken 423 times.
671 if(s_version < 7)
3850
1/2
✓ Branch 0 taken 248 times.
✗ Branch 1 not taken.
248 set_qr(qr_OLD_STRING_EDITOR_MARGINS,true);
3851
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 init_msgstrings(0,msg_strings_size);
3852
3853 671 int32_t string_length=(s_version<2)?73:145;
3854
3855
2/2
✓ Branch 0 taken 133883 times.
✓ Branch 1 taken 671 times.
134554 for(int32_t i=0; i<temp_msg_count; i++)
3856 {
3857
1/2
✓ Branch 0 taken 133883 times.
✗ Branch 1 not taken.
133883 init_msgstr(&tempMsgString);
3858 133883 tempMsgString.listpos = i;
3859
2/2
✓ Branch 0 taken 5689 times.
✓ Branch 1 taken 128194 times.
133883 if(s_version > 8)
3860 {
3861
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_igetl(&string_length,f))
3862 {
3863 return qe_invalid;
3864 }
3865 5689 }
3866
3867
2/4
✓ Branch 0 taken 133883 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 133883 times.
133883 if (string_length < 0 || string_length > 8193)
3868 {
3869 return qe_invalid;
3870 }
3871
3872
2/2
✓ Branch 0 taken 133361 times.
✓ Branch 1 taken 522 times.
133883 if (string_length > 0)
3873 {
3874
2/4
✓ Branch 0 taken 133361 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133361 times.
✗ Branch 3 not taken.
133361 if (!pfread(buf, string_length, f))
3875 {
3876 return qe_invalid;
3877 }
3878 133361 }
3879 else
3880 {
3881 522 buf[0] = 0;
3882 }
3883
3884
2/4
✓ Branch 0 taken 133883 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 133883 times.
✗ Branch 3 not taken.
133883 if(!p_igetw(&tempMsgString.nextstring,f))
3885 {
3886 return qe_invalid;
3887 }
3888
3889
2/2
✓ Branch 0 taken 33613 times.
✓ Branch 1 taken 100270 times.
133883 if(s_version<2)
3890 {
3891 33613 buf[72] = '\0';
3892
1/2
✓ Branch 0 taken 33613 times.
✗ Branch 1 not taken.
33613 tempMsgString.s = buf;
3893 33613 }
3894 else
3895 {
3896 // June 2008: A bug corrupted the last 4 chars of a string.
3897 // Discard these.
3898
1/2
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
100270 if(s_version<3)
3899 {
3900 for(int32_t j=140; j<144; j++)
3901 {
3902 buf[j] = '\0';
3903 }
3904 }
3905
1/2
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
100270 if(string_length > 8192) string_length = 8192;
3906 100270 buf[string_length]='\0'; //Force-terminate
3907
1/2
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
100270 tempMsgString.s = buf;
3908
3909
2/2
✓ Branch 0 taken 5689 times.
✓ Branch 1 taken 94581 times.
100270 if ( s_version >= 6 )
3910 {
3911
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_igetl(&tempMsgString.tile,f))
3912 {
3913 return qe_invalid;
3914 }
3915 5689 }
3916 else
3917 {
3918
2/4
✓ Branch 0 taken 94581 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94581 times.
✗ Branch 3 not taken.
94581 if(!p_igetw(&tempMsgString.tile,f))
3919 {
3920 return qe_invalid;
3921 }
3922 }
3923
3924
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_getc(&tempMsgString.cset,f))
3925 {
3926 return qe_invalid;
3927 }
3928
3929 byte dummy_char;
3930
3931
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_getc(&dummy_char,f)) // trans is stored as a char...
3932 {
3933 return qe_invalid;
3934 }
3935
3936 100270 tempMsgString.trans=dummy_char!=0;
3937
3938
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_getc(&tempMsgString.font,f))
3939 {
3940 return qe_invalid;
3941 }
3942
3943
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100270 times.
100270 if(s_version < 5)
3944 {
3945 if(!p_getc(&tempMsgString.y,f))
3946 {
3947 return qe_invalid;
3948 }
3949 }
3950 else
3951 {
3952
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_igetw(&tempMsgString.x,f))
3953 {
3954 return qe_invalid;
3955 }
3956
3957
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_igetw(&tempMsgString.y,f))
3958 {
3959 return qe_invalid;
3960 }
3961
3962
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_igetw(&tempMsgString.w,f))
3963 {
3964 return qe_invalid;
3965 }
3966
3967
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_igetw(&tempMsgString.h,f))
3968 {
3969 return qe_invalid;
3970 }
3971
3972
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_getc(&tempMsgString.hspace,f))
3973 {
3974 return qe_invalid;
3975 }
3976
3977
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_getc(&tempMsgString.vspace,f))
3978 {
3979 return qe_invalid;
3980 }
3981
3982
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_getc(&tempMsgString.stringflags,f))
3983 {
3984 return qe_invalid;
3985 }
3986 }
3987
3988
2/2
✓ Branch 0 taken 94581 times.
✓ Branch 1 taken 5689 times.
100270 if(s_version >= 7)
3989 {
3990
2/2
✓ Branch 0 taken 5689 times.
✓ Branch 1 taken 22756 times.
28445 for(int32_t q = 0; q < 4; ++q)
3991 {
3992
2/4
✓ Branch 0 taken 22756 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 22756 times.
✗ Branch 3 not taken.
22756 if(!p_getc(&tempMsgString.margins[q],f))
3993 {
3994 return qe_invalid;
3995 }
3996 22756 }
3997
3998
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_igetl(&tempMsgString.portrait_tile,f))
3999 {
4000 return qe_invalid;
4001 }
4002
4003
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_getc(&tempMsgString.portrait_cset,f))
4004 {
4005 return qe_invalid;
4006 }
4007
4008
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_getc(&tempMsgString.portrait_x,f))
4009 {
4010 return qe_invalid;
4011 }
4012
4013
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_getc(&tempMsgString.portrait_y,f))
4014 {
4015 return qe_invalid;
4016 }
4017
4018
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_getc(&tempMsgString.portrait_tw,f))
4019 {
4020 return qe_invalid;
4021 }
4022
4023
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_getc(&tempMsgString.portrait_th,f))
4024 {
4025 return qe_invalid;
4026 }
4027 5689 }
4028
4029
2/2
✓ Branch 0 taken 5689 times.
✓ Branch 1 taken 94581 times.
100270 if(s_version >= 8)
4030 {
4031
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_getc(&tempMsgString.shadow_type,f))
4032 {
4033 return qe_invalid;
4034 }
4035
4036
2/4
✓ Branch 0 taken 5689 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5689 times.
✗ Branch 3 not taken.
5689 if(!p_getc(&tempMsgString.shadow_color,f))
4037 {
4038 return qe_invalid;
4039 }
4040 5689 }
4041
4042
2/2
✓ Branch 0 taken 5380 times.
✓ Branch 1 taken 94890 times.
100270 if(s_version >= 10)
4043 {
4044
2/4
✓ Branch 0 taken 5380 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5380 times.
✗ Branch 3 not taken.
5380 if(!p_getc(&tempMsgString.drawlayer,f))
4045 {
4046 return qe_invalid;
4047 }
4048 5380 }
4049
4050
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_getc(&tempMsgString.sfx,f))
4051 {
4052 return qe_invalid;
4053 }
4054
4055
1/2
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
100270 if(s_version>3)
4056 {
4057
2/4
✓ Branch 0 taken 100270 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 100270 times.
✗ Branch 3 not taken.
100270 if(!p_igetw(&tempMsgString.listpos,f))
4058 {
4059 return qe_invalid;
4060 }
4061 100270 }
4062 }
4063
4064
1/2
✓ Branch 0 taken 133883 times.
✗ Branch 1 not taken.
133883 MsgStrings[i].copyAll(tempMsgString);
4065 133883 }
4066 }
4067
4068
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 694 times.
695 if (!should_skip)
4069 694 msg_count=temp_msg_count;
4070
4071 695 return 0;
4072 695 }
4073
4074 695 int32_t readdoorcombosets(PACKFILE *f, zquestheader *Header)
4075 {
4076
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_doors);
4077
4078
3/4
✓ Branch 0 taken 677 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
701 if((Header->zelda_version < 0x192)||
4079
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 671 times.
677 ((Header->zelda_version == 0x192)&&(Header->build<158)))
4080 {
4081 18 return 0;
4082 }
4083
4084 677 word temp_door_combo_set_count=0;
4085 DoorComboSet tempDoorComboSet;
4086 word dummy_word;
4087 int32_t dummy_long;
4088 byte padding;
4089 677 int32_t s_version = 0;
4090
4091
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 676 times.
677 if (!should_skip)
4092
2/2
✓ Branch 0 taken 173056 times.
✓ Branch 1 taken 676 times.
173732 for(int32_t i=0; i<MAXDOORCOMBOSETS; i++)
4093 {
4094 173056 memset(DoorComboSets+i, 0, sizeof(DoorComboSet));
4095 173732 }
4096
4097
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 671 times.
677 if(Header->zelda_version > 0x192)
4098 {
4099 //section version info
4100
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_version,f))
4101 {
4102 return qe_invalid;
4103 }
4104
4105 671 FFCore.quest_format[vDoors] = s_version;
4106
4107
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&dummy_word,f))
4108 {
4109 return qe_invalid;
4110 }
4111
4112 //section size
4113
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&dummy_long,f))
4114 {
4115 return qe_invalid;
4116 }
4117 671 }
4118
4119 //finally... section data
4120
1/2
✓ Branch 0 taken 677 times.
✗ Branch 1 not taken.
677 if(!p_igetw(&temp_door_combo_set_count,f))
4121 {
4122 return qe_invalid;
4123 }
4124
4125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 677 times.
677 if (temp_door_combo_set_count > MAXDOORCOMBOSETS)
4126 {
4127 return qe_invalid;
4128 }
4129
4130
2/2
✓ Branch 0 taken 5657 times.
✓ Branch 1 taken 677 times.
6334 for(int32_t i=0; i<temp_door_combo_set_count; i++)
4131 {
4132 5657 memset(&tempDoorComboSet, 0, sizeof(DoorComboSet));
4133
4134 //name
4135
1/2
✓ Branch 0 taken 5657 times.
✗ Branch 1 not taken.
5657 if(!pfread(&tempDoorComboSet.name,sizeof(tempDoorComboSet.name),f))
4136 {
4137 return qe_invalid;
4138 }
4139
4140
2/2
✓ Branch 0 taken 5617 times.
✓ Branch 1 taken 40 times.
5657 if(Header->zelda_version < 0x193)
4141 {
4142
1/2
✓ Branch 0 taken 40 times.
✗ Branch 1 not taken.
40 if(!p_getc(&padding,f))
4143 {
4144 return qe_invalid;
4145 }
4146 40 }
4147
4148 //up door
4149
2/2
✓ Branch 0 taken 50913 times.
✓ Branch 1 taken 5657 times.
56570 for(int32_t j=0; j<9; j++)
4150 {
4151
2/2
✓ Branch 0 taken 203652 times.
✓ Branch 1 taken 50913 times.
254565 for(int32_t k=0; k<4; k++)
4152 {
4153
1/2
✓ Branch 0 taken 203652 times.
✗ Branch 1 not taken.
203652 if(!p_igetw(&tempDoorComboSet.doorcombo_u[j][k],f))
4154 {
4155 return qe_invalid;
4156 }
4157 203652 }
4158 50913 }
4159
4160
2/2
✓ Branch 0 taken 50913 times.
✓ Branch 1 taken 5657 times.
56570 for(int32_t j=0; j<9; j++)
4161 {
4162
2/2
✓ Branch 0 taken 203652 times.
✓ Branch 1 taken 50913 times.
254565 for(int32_t k=0; k<4; k++)
4163 {
4164
1/2
✓ Branch 0 taken 203652 times.
✗ Branch 1 not taken.
203652 if(!p_getc(&tempDoorComboSet.doorcset_u[j][k],f))
4165 {
4166 return qe_invalid;
4167 }
4168 203652 }
4169 50913 }
4170
4171 //down door
4172
2/2
✓ Branch 0 taken 50913 times.
✓ Branch 1 taken 5657 times.
56570 for(int32_t j=0; j<9; j++)
4173 {
4174
2/2
✓ Branch 0 taken 203652 times.
✓ Branch 1 taken 50913 times.
254565 for(int32_t k=0; k<4; k++)
4175 {
4176
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203652 times.
203652 if(!p_igetw(&tempDoorComboSet.doorcombo_d[j][k],f))
4177 {
4178 return qe_invalid;
4179 }
4180 203652 }
4181 50913 }
4182
4183
2/2
✓ Branch 0 taken 50913 times.
✓ Branch 1 taken 5657 times.
56570 for(int32_t j=0; j<9; j++)
4184 {
4185
2/2
✓ Branch 0 taken 203652 times.
✓ Branch 1 taken 50913 times.
254565 for(int32_t k=0; k<4; k++)
4186 {
4187
1/2
✓ Branch 0 taken 203652 times.
✗ Branch 1 not taken.
203652 if(!p_getc(&tempDoorComboSet.doorcset_d[j][k],f))
4188 {
4189 return qe_invalid;
4190 }
4191 203652 }
4192 50913 }
4193
4194 //left door
4195
2/2
✓ Branch 0 taken 50913 times.
✓ Branch 1 taken 5657 times.
56570 for(int32_t j=0; j<9; j++)
4196 {
4197
2/2
✓ Branch 0 taken 305478 times.
✓ Branch 1 taken 50913 times.
356391 for(int32_t k=0; k<6; k++)
4198 {
4199
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 305478 times.
305478 if(!p_igetw(&tempDoorComboSet.doorcombo_l[j][k],f))
4200 {
4201 return qe_invalid;
4202 }
4203 305478 }
4204 50913 }
4205
4206
2/2
✓ Branch 0 taken 50913 times.
✓ Branch 1 taken 5657 times.
56570 for(int32_t j=0; j<9; j++)
4207 {
4208
2/2
✓ Branch 0 taken 305478 times.
✓ Branch 1 taken 50913 times.
356391 for(int32_t k=0; k<6; k++)
4209 {
4210
1/2
✓ Branch 0 taken 305478 times.
✗ Branch 1 not taken.
305478 if(!p_getc(&tempDoorComboSet.doorcset_l[j][k],f))
4211 {
4212 return qe_invalid;
4213 }
4214 305478 }
4215 50913 }
4216
4217 //right door
4218
2/2
✓ Branch 0 taken 50913 times.
✓ Branch 1 taken 5657 times.
56570 for(int32_t j=0; j<9; j++)
4219 {
4220
2/2
✓ Branch 0 taken 305478 times.
✓ Branch 1 taken 50913 times.
356391 for(int32_t k=0; k<6; k++)
4221 {
4222
1/2
✓ Branch 0 taken 305478 times.
✗ Branch 1 not taken.
305478 if(!p_igetw(&tempDoorComboSet.doorcombo_r[j][k],f))
4223 {
4224 return qe_invalid;
4225 }
4226 305478 }
4227 50913 }
4228
4229
2/2
✓ Branch 0 taken 50913 times.
✓ Branch 1 taken 5657 times.
56570 for(int32_t j=0; j<9; j++)
4230 {
4231
2/2
✓ Branch 0 taken 305478 times.
✓ Branch 1 taken 50913 times.
356391 for(int32_t k=0; k<6; k++)
4232 {
4233
1/2
✓ Branch 0 taken 305478 times.
✗ Branch 1 not taken.
305478 if(!p_getc(&tempDoorComboSet.doorcset_r[j][k],f))
4234 {
4235 return qe_invalid;
4236 }
4237 305478 }
4238 50913 }
4239
4240 //up bomb rubble
4241
2/2
✓ Branch 0 taken 11314 times.
✓ Branch 1 taken 5657 times.
16971 for(int32_t j=0; j<2; j++)
4242 {
4243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11314 times.
11314 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_u[j],f))
4244 {
4245 return qe_invalid;
4246 }
4247 11314 }
4248
4249
2/2
✓ Branch 0 taken 11314 times.
✓ Branch 1 taken 5657 times.
16971 for(int32_t j=0; j<2; j++)
4250 {
4251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11314 times.
11314 if(!p_getc(&tempDoorComboSet.bombdoorcset_u[j],f))
4252 {
4253 return qe_invalid;
4254 }
4255 11314 }
4256
4257 //down bomb rubble
4258
2/2
✓ Branch 0 taken 11314 times.
✓ Branch 1 taken 5657 times.
16971 for(int32_t j=0; j<2; j++)
4259 {
4260
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11314 times.
11314 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_d[j],f))
4261 {
4262 return qe_invalid;
4263 }
4264 11314 }
4265
4266
2/2
✓ Branch 0 taken 11314 times.
✓ Branch 1 taken 5657 times.
16971 for(int32_t j=0; j<2; j++)
4267 {
4268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11314 times.
11314 if(!p_getc(&tempDoorComboSet.bombdoorcset_d[j],f))
4269 {
4270 return qe_invalid;
4271 }
4272 11314 }
4273
4274 //left bomb rubble
4275
2/2
✓ Branch 0 taken 16971 times.
✓ Branch 1 taken 5657 times.
22628 for(int32_t j=0; j<3; j++)
4276 {
4277
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16971 times.
16971 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_l[j],f))
4278 {
4279 return qe_invalid;
4280 }
4281 16971 }
4282
4283
2/2
✓ Branch 0 taken 16971 times.
✓ Branch 1 taken 5657 times.
22628 for(int32_t j=0; j<3; j++)
4284 {
4285
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16971 times.
16971 if(!p_getc(&tempDoorComboSet.bombdoorcset_l[j],f))
4286 {
4287 return qe_invalid;
4288 }
4289 16971 }
4290
4291
2/2
✓ Branch 0 taken 5617 times.
✓ Branch 1 taken 40 times.
5657 if(Header->zelda_version < 0x193)
4292 {
4293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4294 {
4295 return qe_invalid;
4296 }
4297
4298 40 }
4299
4300 //right bomb rubble
4301
2/2
✓ Branch 0 taken 16971 times.
✓ Branch 1 taken 5657 times.
22628 for(int32_t j=0; j<3; j++)
4302 {
4303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16971 times.
16971 if(!p_igetw(&tempDoorComboSet.bombdoorcombo_r[j],f))
4304 {
4305 return qe_invalid;
4306 }
4307 16971 }
4308
4309
2/2
✓ Branch 0 taken 16971 times.
✓ Branch 1 taken 5657 times.
22628 for(int32_t j=0; j<3; j++)
4310 {
4311
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16971 times.
16971 if(!p_getc(&tempDoorComboSet.bombdoorcset_r[j],f))
4312 {
4313 return qe_invalid;
4314 }
4315 16971 }
4316
4317
2/2
✓ Branch 0 taken 5617 times.
✓ Branch 1 taken 40 times.
5657 if(Header->zelda_version < 0x193)
4318 {
4319
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!p_getc(&padding,f))
4320 {
4321 return qe_invalid;
4322 }
4323 40 }
4324
4325 //walkthrough stuff
4326
2/2
✓ Branch 0 taken 22628 times.
✓ Branch 1 taken 5657 times.
28285 for(int32_t j=0; j<4; j++)
4327 {
4328
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22628 times.
22628 if(!p_igetw(&tempDoorComboSet.walkthroughcombo[j],f))
4329 {
4330 return qe_invalid;
4331 }
4332 22628 }
4333
4334
2/2
✓ Branch 0 taken 22628 times.
✓ Branch 1 taken 5657 times.
28285 for(int32_t j=0; j<4; j++)
4335 {
4336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22628 times.
22628 if(!p_getc(&tempDoorComboSet.walkthroughcset[j],f))
4337 {
4338 return qe_invalid;
4339 }
4340 22628 }
4341
4342 //flags
4343
2/2
✓ Branch 0 taken 11314 times.
✓ Branch 1 taken 5657 times.
16971 for(int32_t j=0; j<2; j++)
4344 {
4345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11314 times.
11314 if(!p_getc(&tempDoorComboSet.flags[j],f))
4346 {
4347 return qe_invalid;
4348 }
4349 11314 }
4350
4351
2/2
✓ Branch 0 taken 5617 times.
✓ Branch 1 taken 40 times.
5657 if(Header->zelda_version < 0x193)
4352 {
4353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 40 times.
40 if(!pfread(&tempDoorComboSet.expansion,sizeof(tempDoorComboSet.expansion),f))
4354 {
4355 return qe_invalid;
4356 }
4357 40 }
4358
4359
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 5643 times.
5657 if (!should_skip)
4360 5643 memcpy(&DoorComboSets[i], &tempDoorComboSet, sizeof(tempDoorComboSet));
4361 5657 }
4362
4363
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 676 times.
677 if (!should_skip)
4364 676 door_combo_set_count=temp_door_combo_set_count;
4365
4366 677 return 0;
4367 695 }
4368
4369 6 int32_t count_dmaps()
4370 {
4371 6 int32_t i=MAXDMAPS-1;
4372 6 bool found=false;
4373
4374
4/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 12 times.
✓ Branch 3 taken 6 times.
6 while(i>=0 && !found)
4375 {
4376
4/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
18 if((DMaps[i].map!=0)||(DMaps[i].level!=0)||(DMaps[i].xoff!=0)||
4377
3/6
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
6 (DMaps[i].compass!=0)||(DMaps[i].color!=0)||(DMaps[i].midi!=0)||
4378
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 (DMaps[i].cont!=0)||(DMaps[i].type!=0))
4379 12 found=true;
4380
4381
2/2
✓ Branch 0 taken 48 times.
✓ Branch 1 taken 12 times.
60 for(int32_t j=0; j<8; j++)
4382 {
4383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48 times.
48 if(DMaps[i].grid[j]!=0)
4384
4385 found=true;
4386 48 }
4387
4388
5/6
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
✓ Branch 4 taken 6 times.
✓ Branch 5 taken 6 times.
12 if((DMaps[i].name[0]!=0)||(DMaps[i].title[0]!=0)||
4389 (DMaps[i].intro[0]!=0)||(DMaps[i].tmusic[0]!=0))
4390 18 found=true;
4391
4392
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 6 times.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
18 if((DMaps[i].minimap_1_tile!=0)||(DMaps[i].minimap_2_tile!=0)||
4393
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 (DMaps[i].largemap_1_tile!=0)||(DMaps[i].largemap_2_tile!=0)||
4394
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 (DMaps[i].minimap_1_cset!=0)||(DMaps[i].minimap_2_cset!=0)||
4395
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 (DMaps[i].largemap_1_cset!=0)||(DMaps[i].largemap_2_cset!=0))
4396 12 found=true;
4397
4398 if(!found)
4399 {
4400 i--;
4401 }
4402 }
4403
4404 6 return i+1;
4405 }
4406
4407
4408 6 int32_t count_shops(miscQdata *Misc)
4409 {
4410 6 int32_t i=NUM_SHOPS-1,j;
4411 6 bool found=false;
4412
4413
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1480 times.
✓ Branch 2 taken 1476 times.
✓ Branch 3 taken 6 times.
1482 while(i>=0 && !found)
4414 {
4415 1476 j=2;
4416
4417
4/4
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 4424 times.
✓ Branch 2 taken 4420 times.
✓ Branch 3 taken 1476 times.
5896 while(j>=0 && !found)
4418 {
4419
3/4
✓ Branch 0 taken 4416 times.
✓ Branch 1 taken 4 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4416 times.
4420 if((Misc->shop[i].hasitem[j]!=0)||(Misc->shop[i].price[j]!=0))
4420 {
4421 4 found=true;
4422 4 }
4423 else
4424 {
4425 4416 j--;
4426 }
4427 }
4428
4429
1/2
✓ Branch 0 taken 1476 times.
✗ Branch 1 not taken.
1476 if(Misc->shop[i].name[0]!=0)
4430 {
4431 found=true;
4432 }
4433
4434
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1472 times.
1476 if(!found)
4435 {
4436 1472 i--;
4437 1472 }
4438 }
4439
4440 6 return i+1;
4441 }
4442
4443 6 int32_t count_infos(miscQdata *Misc)
4444 {
4445 6 int32_t i=255,j;
4446 6 bool found=false;
4447
4448
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1480 times.
✓ Branch 2 taken 1476 times.
✓ Branch 3 taken 6 times.
1482 while(i>=0 && !found)
4449 {
4450 1476 j=2;
4451
4452
4/4
✓ Branch 0 taken 1472 times.
✓ Branch 1 taken 4424 times.
✓ Branch 2 taken 4420 times.
✓ Branch 3 taken 1476 times.
5896 while(j>=0 && !found)
4453 {
4454
4/4
✓ Branch 0 taken 4419 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 4416 times.
4420 if((Misc->info[i].str[j]!=0)||(Misc->info[i].price[j]!=0))
4455 {
4456 4 found=true;
4457 4 }
4458 else
4459 {
4460 4416 j--;
4461 }
4462 }
4463
4464
1/2
✓ Branch 0 taken 1476 times.
✗ Branch 1 not taken.
1476 if(Misc->info[i].name[0]!=0)
4465 {
4466 found=true;
4467 }
4468
4469
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1472 times.
1476 if(!found)
4470 {
4471 1472 i--;
4472 1472 }
4473 }
4474
4475 6 return i+1;
4476 }
4477
4478 6 int32_t count_warprings(miscQdata *Misc)
4479 {
4480 6 int32_t i=15,j;
4481 6 bool found=false;
4482
4483
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 36 times.
✓ Branch 2 taken 30 times.
✓ Branch 3 taken 6 times.
36 while(i>=0 && !found)
4484 {
4485 30 j=7;
4486
4487
4/4
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 222 times.
✓ Branch 2 taken 216 times.
✓ Branch 3 taken 30 times.
246 while(j>=0 && !found)
4488 {
4489
4/4
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 3 times.
✓ Branch 2 taken 3 times.
✓ Branch 3 taken 210 times.
216 if((Misc->warp[i].dmap[j]!=0)||(Misc->warp[i].scr[j]!=0))
4490 {
4491 6 found=true;
4492 6 }
4493 else
4494 {
4495 210 j--;
4496 }
4497 }
4498
4499
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 24 times.
30 if(!found)
4500 {
4501 24 i--;
4502 24 }
4503 }
4504
4505 6 return i+1;
4506 }
4507
4508 6 int32_t count_palcycles(miscQdata *Misc)
4509 {
4510 6 int32_t i=255,j;
4511 6 bool found=false;
4512
4513
4/4
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 1406 times.
✓ Branch 2 taken 1402 times.
✓ Branch 3 taken 6 times.
1408 while(i>=0 && !found)
4514 {
4515 1402 j=2;
4516
4517
4/4
✓ Branch 0 taken 1398 times.
✓ Branch 1 taken 4202 times.
✓ Branch 2 taken 4198 times.
✓ Branch 3 taken 1402 times.
5600 while(j>=0 && !found)
4518 {
4519
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 4194 times.
4198 if(Misc->cycles[i][j].count!=0)
4520 {
4521 4 found=true;
4522 4 }
4523 else
4524 {
4525 4194 j--;
4526 }
4527 }
4528
4529
2/2
✓ Branch 0 taken 4 times.
✓ Branch 1 taken 1398 times.
1402 if(!found)
4530 {
4531 1398 i--;
4532 1398 }
4533 }
4534
4535 6 return i+1;
4536 }
4537
4538 1336767 void clear_screen(mapscr *temp_scr)
4539 {
4540 1336767 temp_scr->zero_memory();
4541 1336767 }
4542
4543 // NOTE: when modifying this, you need to also update:
4544 // readonedmap, readdmaps, and FFScript::read_dmaps
4545 // (and their associated write functions)
4546 3767 int32_t readdmaps(PACKFILE *f, zquestheader *Header, word, word, word start_dmap, word max_dmaps)
4547 {
4548
2/2
✓ Branch 0 taken 3743 times.
✓ Branch 1 taken 24 times.
3767 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_dmaps);
4549
4550 3767 word dmapstoread=0;
4551 3767 dmap tempDMap;
4552
4553 int32_t dummy;
4554 3767 word s_version=0, s_cversion=0;
4555 byte padding;
4556
4557 char legacy_title[22];
4558
4559
2/2
✓ Branch 0 taken 3073 times.
✓ Branch 1 taken 694 times.
3767 if (!should_skip)
4560
2/2
✓ Branch 0 taken 355328 times.
✓ Branch 1 taken 694 times.
356022 for(int32_t i=0; i<max_dmaps; i++)
4561 {
4562
1/2
✓ Branch 0 taken 355328 times.
✗ Branch 1 not taken.
355328 DMaps[start_dmap + i].clear();
4563 355328 sprintf(legacy_title," ");
4564 355328 sprintf(DMaps[start_dmap+i].intro," ");
4565 355328 DMaps[start_dmap+i].type |= dmCAVE;
4566 356022 }
4567
4568
4/4
✓ Branch 0 taken 695 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 671 times.
✓ Branch 3 taken 24 times.
3767 if(!Header || Header->zelda_version > 0x192)
4569 {
4570 //section version info
4571
3/4
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 3072 times.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
3743 if(!p_igetw(&s_version,f))
4572 {
4573 return qe_invalid;
4574 }
4575
4576 671 FFCore.quest_format[vDMaps] = s_version;
4577
4578
4579
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&s_cversion,f))
4580 {
4581 return qe_invalid;
4582 }
4583
4584 //section size
4585
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetl(&dummy,f))
4586 {
4587 return qe_invalid;
4588 }
4589
4590 //finally... section data
4591
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&dmapstoread,f))
4592 {
4593 return qe_invalid;
4594 }
4595 671 }
4596 else
4597 {
4598
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
4599
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<5)))
4600 {
4601 18 dmapstoread=32;
4602 18 }
4603
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 else if(s_version <= 4)
4604 {
4605 6 dmapstoread=OLDMAXDMAPS;
4606 6 }
4607 else
4608 {
4609 dmapstoread=MAXDMAPS;
4610 }
4611 }
4612
4613
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 612 times.
695 dmapstoread=zc_min(dmapstoread, max_dmaps);
4614
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 612 times.
695 dmapstoread=zc_min(dmapstoread, MAXDMAPS-start_dmap);
4615
4616
2/2
✓ Branch 0 taken 330560 times.
✓ Branch 1 taken 695 times.
331255 for(int32_t i=start_dmap; i<dmapstoread+start_dmap; i++)
4617 {
4618
1/2
✓ Branch 0 taken 330560 times.
✗ Branch 1 not taken.
330560 tempDMap.clear();
4619 330560 sprintf(legacy_title," ");
4620 330560 sprintf(tempDMap.intro," ");
4621
4622
2/4
✓ Branch 0 taken 330560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330560 times.
✗ Branch 3 not taken.
330560 if(!p_getc(&tempDMap.map,f))
4623 {
4624 return qe_invalid;
4625 }
4626
4627
2/2
✓ Branch 0 taken 17216 times.
✓ Branch 1 taken 313344 times.
330560 if(s_version <= 4)
4628 {
4629 byte tempbyte;
4630
4631
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4632 {
4633 return qe_invalid;
4634 }
4635
4636 17216 tempDMap.level=(word)tempbyte;
4637 17216 }
4638 else
4639 {
4640
2/4
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 313344 times.
✗ Branch 3 not taken.
313344 if(!p_igetw(&tempDMap.level,f))
4641 {
4642 return qe_invalid;
4643 }
4644 }
4645
4646
2/4
✓ Branch 0 taken 330560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330560 times.
✗ Branch 3 not taken.
330560 if(!p_getc(&tempDMap.xoff,f))
4647 {
4648 return qe_invalid;
4649 }
4650
4651
2/4
✓ Branch 0 taken 330560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330560 times.
✗ Branch 3 not taken.
330560 if(!p_getc(&tempDMap.compass,f))
4652 {
4653 return qe_invalid;
4654 }
4655
4656
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 17216 times.
330560 if(s_version > 8) // February 2009
4657 {
4658
2/4
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 313344 times.
✗ Branch 3 not taken.
313344 if(!p_igetw(&tempDMap.color,f))
4659 {
4660 return qe_invalid;
4661 }
4662 313344 }
4663 else
4664 {
4665 byte tempbyte;
4666
4667
2/4
✓ Branch 0 taken 17216 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 17216 times.
✗ Branch 3 not taken.
17216 if(!p_getc(&tempbyte,f))
4668 {
4669 return qe_invalid;
4670 }
4671
4672 17216 tempDMap.color = (word)tempbyte;
4673 }
4674
4675
2/4
✓ Branch 0 taken 330560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330560 times.
✗ Branch 3 not taken.
330560 if(!p_getc(&tempDMap.midi,f))
4676 {
4677 return qe_invalid;
4678 }
4679
4680
2/4
✓ Branch 0 taken 330560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330560 times.
✗ Branch 3 not taken.
330560 if(!p_getc(&tempDMap.cont,f))
4681 {
4682 return qe_invalid;
4683 }
4684
4685
2/4
✓ Branch 0 taken 330560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 330560 times.
✗ Branch 3 not taken.
330560 if(!p_getc(&tempDMap.type,f))
4686 {
4687 return qe_invalid;
4688 }
4689
4690
4/4
✓ Branch 0 taken 5487 times.
✓ Branch 1 taken 325073 times.
✓ Branch 2 taken 5443 times.
✓ Branch 3 taken 44 times.
336047 if((tempDMap.type & dmfTYPE) == dmOVERW &&
4691
1/2
✓ Branch 0 taken 5487 times.
✗ Branch 1 not taken.
5487 (!Header || Header->zelda_version >= 0x210)) // Not sure exactly when this changed
4692 5443 tempDMap.xoff = 0;
4693
4694
2/2
✓ Branch 0 taken 330560 times.
✓ Branch 1 taken 2644480 times.
2975040 for(int32_t j=0; j<8; j++)
4695 {
4696
2/4
✓ Branch 0 taken 2644480 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2644480 times.
✗ Branch 3 not taken.
2644480 if(!p_getc(&tempDMap.grid[j],f))
4697 {
4698 return qe_invalid;
4699 }
4700 2644480 }
4701
4702
5/6
✓ Branch 0 taken 330560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329984 times.
✓ Branch 3 taken 576 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 328448 times.
330560 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<41))))
4703 {
4704
4/4
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 1975 times.
✓ Branch 2 taken 10 times.
✓ Branch 3 taken 127 times.
2112 if(tempDMap.level>0&&tempDMap.level<10)
4705 {
4706 127 sprintf(legacy_title,"LEVEL-%d ", tempDMap.level);
4707 127 }
4708
2/2
✓ Branch 0 taken 576 times.
✓ Branch 1 taken 1536 times.
2112 tempDMap.title.assign(legacy_title);
4709
4710
3/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 558 times.
✓ Branch 2 taken 18 times.
✗ Branch 3 not taken.
576 if(i==0 && Header->zelda_version <= 0x190)
4711 {
4712
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.cont = std::max((int)tempDMap.cont - tempDMap.xoff, 0);
4713
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 tempDMap.compass = std::max((int)tempDMap.compass - tempDMap.xoff, 0);
4714 18 }
4715
4716 //forgotten -DD
4717
2/2
✓ Branch 0 taken 137 times.
✓ Branch 1 taken 439 times.
576 if(tempDMap.level==0)
4718 {
4719 439 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4720 439 }
4721 576 }
4722 else
4723 {
4724
3/4
✓ Branch 0 taken 329984 times.
✓ Branch 1 taken 1536 times.
✓ Branch 2 taken 329984 times.
✗ Branch 3 not taken.
328448 if(!p_getstr(tempDMap.name,sizeof(DMaps[0].name) - 1,f))
4725 {
4726 return qe_invalid;
4727 }
4728
4729
2/2
✓ Branch 0 taken 122624 times.
✓ Branch 1 taken 207360 times.
329984 if(s_version<20)
4730 {
4731
2/4
✓ Branch 0 taken 122624 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 122624 times.
✗ Branch 3 not taken.
122624 if (!p_getstr(legacy_title, sizeof(legacy_title) - 1, f))
4732 {
4733 return qe_invalid;
4734 }
4735
1/2
✓ Branch 0 taken 122624 times.
✗ Branch 1 not taken.
122624 tempDMap.title.assign(legacy_title);
4736 122624 }
4737 else
4738 {
4739
2/4
✓ Branch 0 taken 207360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207360 times.
✗ Branch 3 not taken.
207360 if (!p_getwstr(&tempDMap.title, f))
4740 {
4741 return qe_invalid;
4742 }
4743 }
4744
4745
2/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329984 times.
✗ Branch 3 not taken.
329984 if(!p_getstr(tempDMap.intro,sizeof(DMaps[0].intro)-1,f))
4746 {
4747 return qe_invalid;
4748 }
4749
4750
5/8
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329984 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 328448 times.
✗ Branch 6 not taken.
✓ Branch 7 taken 1536 times.
329984 if(Header && ((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<152))))
4751 {
4752 if ((tempDMap.type & dmfTYPE) == dmOVERW) tempDMap.flags = dmfCAVES | dmf3STAIR | dmfWHIRLWIND | dmfGUYCAVES;
4753 DMaps[i] = tempDMap;
4754
4755 continue;
4756 }
4757
4758
3/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 328448 times.
329984 if(Header && (Header->zelda_version < 0x193))
4759 {
4760
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4761 {
4762 return qe_invalid;
4763 }
4764 1536 }
4765
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113408 times.
329984 if ( s_version >= 11 )
4766 {
4767
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_igetl(&tempDMap.minimap_1_tile,f))
4768 {
4769 return qe_invalid;
4770 }
4771 216576 }
4772 else
4773 {
4774
2/4
✓ Branch 0 taken 113408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113408 times.
✗ Branch 3 not taken.
113408 if(!p_igetw(&tempDMap.minimap_1_tile,f))
4775 {
4776 return qe_invalid;
4777 }
4778 }
4779
4780
2/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329984 times.
✗ Branch 3 not taken.
329984 if(!p_getc(&tempDMap.minimap_1_cset,f))
4781 {
4782 return qe_invalid;
4783 }
4784
4785
3/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 328448 times.
329984 if(Header && (Header->zelda_version < 0x193))
4786 {
4787
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4788 {
4789 return qe_invalid;
4790 }
4791 1536 }
4792
4793
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113408 times.
329984 if ( s_version >= 11 )
4794 {
4795
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_igetl(&tempDMap.minimap_2_tile,f))
4796 {
4797 return qe_invalid;
4798 }
4799 216576 }
4800 else
4801 {
4802
2/4
✓ Branch 0 taken 113408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113408 times.
✗ Branch 3 not taken.
113408 if(!p_igetw(&tempDMap.minimap_2_tile,f))
4803 {
4804 return qe_invalid;
4805 }
4806 }
4807
2/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329984 times.
✗ Branch 3 not taken.
329984 if(!p_getc(&tempDMap.minimap_2_cset,f))
4808 {
4809 return qe_invalid;
4810 }
4811
4812
3/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 328448 times.
329984 if(Header && (Header->zelda_version < 0x193))
4813 {
4814
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4815 {
4816 return qe_invalid;
4817 }
4818 1536 }
4819
4820
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113408 times.
329984 if ( s_version >= 11 )
4821 {
4822
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_igetl(&tempDMap.largemap_1_tile,f))
4823 {
4824 return qe_invalid;
4825 }
4826 216576 }
4827 else
4828 {
4829
2/4
✓ Branch 0 taken 113408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113408 times.
✗ Branch 3 not taken.
113408 if(!p_igetw(&tempDMap.largemap_1_tile,f))
4830 {
4831 return qe_invalid;
4832 }
4833 }
4834
4835
2/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329984 times.
✗ Branch 3 not taken.
329984 if(!p_getc(&tempDMap.largemap_1_cset,f))
4836 {
4837 return qe_invalid;
4838 }
4839
4840
3/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✓ Branch 3 taken 328448 times.
329984 if(Header && (Header->zelda_version < 0x193))
4841 {
4842
4843
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4844 {
4845 return qe_invalid;
4846 }
4847 1536 }
4848
4849
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113408 times.
329984 if ( s_version >= 11 )
4850 {
4851
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_igetl(&tempDMap.largemap_2_tile,f))
4852 {
4853 return qe_invalid;
4854 }
4855 216576 }
4856 else
4857 {
4858
2/4
✓ Branch 0 taken 113408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 113408 times.
✗ Branch 3 not taken.
113408 if(!p_igetw(&tempDMap.largemap_2_tile,f))
4859 {
4860 return qe_invalid;
4861 }
4862 }
4863
2/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329984 times.
✗ Branch 3 not taken.
329984 if(!p_getc(&tempDMap.largemap_2_cset,f))
4864 {
4865 return qe_invalid;
4866 }
4867
4868
2/4
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 329984 times.
✗ Branch 3 not taken.
329984 if(!p_getstr(tempDMap.tmusic,sizeof(DMaps[0].tmusic)-1,f))
4869 {
4870 return qe_invalid;
4871 }
4872 }
4873
4874
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 17216 times.
330560 if(s_version>1)
4875 {
4876
2/4
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 313344 times.
✗ Branch 3 not taken.
313344 if(!p_getc(&tempDMap.tmusictrack,f))
4877 {
4878 return qe_invalid;
4879 }
4880
4881
2/4
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 313344 times.
✗ Branch 3 not taken.
313344 if(!p_getc(&tempDMap.active_subscreen,f))
4882 {
4883 return qe_invalid;
4884 }
4885
4886
2/4
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 313344 times.
✗ Branch 3 not taken.
313344 if(!p_getc(&tempDMap.passive_subscreen,f))
4887 {
4888 return qe_invalid;
4889 }
4890 313344 }
4891
4892
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 17216 times.
330560 if(s_version>2)
4893 {
4894 byte di[32];
4895
4896
2/4
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 313344 times.
✗ Branch 3 not taken.
313344 if(!pfread(&di, 32, f)) return qe_invalid;
4897
4898
2/2
✓ Branch 0 taken 80216064 times.
✓ Branch 1 taken 313344 times.
80529408 for(int32_t j=0; j<MAXITEMS; j++)
4899 {
4900
2/2
✓ Branch 0 taken 9038 times.
✓ Branch 1 taken 80207026 times.
80216064 if(di[j/8] & (1 << (j%8))) tempDMap.disableditems[j]=1;
4901 80207026 else tempDMap.disableditems[j]=0;
4902 80216064 }
4903 313344 }
4904
4905
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 17216 times.
330560 if(s_version >= 6)
4906 {
4907
2/4
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 313344 times.
✗ Branch 3 not taken.
313344 if(!p_igetl(&tempDMap.flags,f))
4908 {
4909 return qe_invalid;
4910 }
4911 313344 }
4912
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17216 times.
17216 else if(s_version>3)
4913 {
4914 char temp;
4915
4916 if(!p_getc(&temp,f))
4917 {
4918 return qe_invalid;
4919 }
4920
4921 tempDMap.flags = temp;
4922 }
4923
3/8
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 8992 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
17216 else if(tempDMap.level==0 && ((Header->zelda_version < 0x211) || ((Header->zelda_version == 0x211) && (Header->build<18))))
4924 {
4925 8992 tempDMap.flags=dmfCAVES|dmf3STAIR|dmfWHIRLWIND|dmfGUYCAVES;
4926 8992 }
4927 else
4928 8224 tempDMap.flags=0;
4929
4930
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 17216 times.
330560 if(s_version<7)
4931 {
4932
5/6
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8992 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2846 times.
✓ Branch 5 taken 6146 times.
17216 if(tempDMap.level==0 && get_bit(deprecated_rules,14))
4933 6146 tempDMap.flags|= dmfVIEWMAP;
4934 17216 }
4935
4936
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 17216 times.
330560 if(s_version<8)
4937 {
4938
4/4
✓ Branch 0 taken 8992 times.
✓ Branch 1 taken 8224 times.
✓ Branch 2 taken 8050 times.
✓ Branch 3 taken 942 times.
17216 if(tempDMap.level==0 && (tempDMap.type&dmfTYPE)==dmDNGN)
4939 {
4940
1/2
✓ Branch 0 taken 8050 times.
✗ Branch 1 not taken.
8050 tempDMap.type &= ~dmDNGN;
4941 8050 tempDMap.type |= dmCAVE;
4942 8050 }
4943
2/2
✓ Branch 0 taken 6834 times.
✓ Branch 1 taken 2332 times.
9166 else if((tempDMap.type&dmfTYPE)==dmCAVE)
4944 {
4945 2332 tempDMap.flags |= dmfMINIMAPCOLORFIX;
4946 2332 }
4947 17216 }
4948
4949
7/8
✓ Branch 0 taken 330560 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2112 times.
✓ Branch 3 taken 328448 times.
✓ Branch 4 taken 1536 times.
✓ Branch 5 taken 576 times.
✓ Branch 6 taken 1536 times.
✓ Branch 7 taken 328448 times.
330560 if(Header && ((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>=41)))
4950 329984 && (Header->zelda_version < 0x193))
4951 {
4952
2/4
✓ Branch 0 taken 1536 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
1536 if(!p_getc(&padding,f))
4953 {
4954 return qe_invalid;
4955 }
4956 1536 }
4957
4958
2/2
✓ Branch 0 taken 113984 times.
✓ Branch 1 taken 216576 times.
330560 if(s_version >= 10)
4959 {
4960
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_getc(&tempDMap.sideview,f))
4961 {
4962 return qe_invalid;
4963 }
4964 216576 }
4965
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113984 times.
330560 if(s_version < 10) tempDMap.sideview = 0;
4966
4967 //Dmap Scripts
4968
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113984 times.
330560 if(s_version >= 12)
4969 {
4970
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_igetw(&tempDMap.script,f))
4971 {
4972 return qe_invalid;
4973 }
4974
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 216576 times.
1949184 for ( int32_t q = 0; q < 8; q++ )
4975 {
4976
2/4
✓ Branch 0 taken 1732608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1732608 times.
✗ Branch 3 not taken.
1732608 if(!p_igetl(&tempDMap.initD[q],f))
4977 {
4978 return qe_invalid;
4979 }
4980 1732608 }
4981 216576 }
4982
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113984 times.
330560 if ( s_version < 12 )
4983 {
4984 113984 tempDMap.script = 0;
4985
2/2
✓ Branch 0 taken 911872 times.
✓ Branch 1 taken 113984 times.
1025856 for ( int32_t q = 0; q < 8; q++ )
4986 {
4987 911872 tempDMap.initD[q] = 0;
4988 911872 }
4989 113984 }
4990
4991
2/2
✓ Branch 0 taken 113984 times.
✓ Branch 1 taken 216576 times.
330560 if(s_version >= 13)
4992 {
4993
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 216576 times.
1949184 for ( int32_t q = 0; q < 8; q++ )
4994 {
4995
2/2
✓ Branch 0 taken 112619520 times.
✓ Branch 1 taken 1732608 times.
114352128 for ( int32_t w = 0; w < 65; w++ )
4996 {
4997
2/4
✓ Branch 0 taken 112619520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112619520 times.
✗ Branch 3 not taken.
112619520 if(!p_getc(&tempDMap.initD_label[q][w],f))
4998 {
4999 return qe_invalid;
5000 }
5001 112619520 }
5002 1732608 }
5003 216576 }
5004
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113984 times.
330560 if ( s_version < 13 )
5005 {
5006 113984 tempDMap.script = 0;
5007
2/2
✓ Branch 0 taken 911872 times.
✓ Branch 1 taken 113984 times.
1025856 for ( int32_t q = 0; q < 8; q++ )
5008 {
5009
2/2
✓ Branch 0 taken 59271680 times.
✓ Branch 1 taken 911872 times.
60183552 for ( int32_t w = 0; w < 65; w++ )
5010 59271680 tempDMap.initD_label[q][w] = 0;
5011 911872 }
5012 113984 }
5013
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113984 times.
330560 if(s_version >= 14)
5014 {
5015
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_igetw(&tempDMap.active_sub_script,f))
5016 {
5017 return qe_invalid;
5018 }
5019
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_igetw(&tempDMap.passive_sub_script,f))
5020 {
5021 return qe_invalid;
5022 }
5023
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 216576 times.
1949184 for ( int32_t q = 0; q < 8; ++q )
5024 {
5025
2/4
✓ Branch 0 taken 1732608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1732608 times.
✗ Branch 3 not taken.
1732608 if(!p_igetl(&tempDMap.sub_initD[q],f))
5026 {
5027 return qe_invalid;
5028 }
5029 1732608 }
5030
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 216576 times.
1949184 for(int32_t q = 0; q < 8; ++q)
5031 {
5032
2/2
✓ Branch 0 taken 112619520 times.
✓ Branch 1 taken 1732608 times.
114352128 for ( int32_t w = 0; w < 65; ++w )
5033 {
5034
2/4
✓ Branch 0 taken 112619520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112619520 times.
✗ Branch 3 not taken.
112619520 if(!p_getc(&tempDMap.sub_initD_label[q][w],f))
5035 {
5036 return qe_invalid;
5037 }
5038 112619520 }
5039 1732608 }
5040 216576 }
5041 else
5042 {
5043 113984 tempDMap.active_sub_script = 0;
5044 113984 tempDMap.passive_sub_script = 0;
5045
2/2
✓ Branch 0 taken 911872 times.
✓ Branch 1 taken 113984 times.
1025856 for(int32_t q = 0; q < 8; ++q)
5046 {
5047 911872 tempDMap.sub_initD[q] = 0;
5048
2/2
✓ Branch 0 taken 59271680 times.
✓ Branch 1 taken 911872 times.
60183552 for(int32_t w = 0; w < 65; ++w)
5049 59271680 tempDMap.sub_initD_label[q][w] = 0;
5050 911872 }
5051 }
5052
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113984 times.
330560 if(s_version >= 15)
5053 {
5054
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_igetw(&tempDMap.onmap_script,f))
5055 {
5056 return qe_invalid;
5057 }
5058
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 216576 times.
1949184 for ( int32_t q = 0; q < 8; ++q )
5059 {
5060
2/4
✓ Branch 0 taken 1732608 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1732608 times.
✗ Branch 3 not taken.
1732608 if(!p_igetl(&tempDMap.onmap_initD[q],f))
5061 {
5062 return qe_invalid;
5063 }
5064 1732608 }
5065
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 216576 times.
1949184 for(int32_t q = 0; q < 8; ++q)
5066 {
5067
2/2
✓ Branch 0 taken 112619520 times.
✓ Branch 1 taken 1732608 times.
114352128 for ( int32_t w = 0; w < 65; ++w )
5068 {
5069
2/4
✓ Branch 0 taken 112619520 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 112619520 times.
✗ Branch 3 not taken.
112619520 if(!p_getc(&tempDMap.onmap_initD_label[q][w],f))
5070 {
5071 return qe_invalid;
5072 }
5073 112619520 }
5074 1732608 }
5075 216576 }
5076 else
5077 {
5078 113984 tempDMap.onmap_script = 0;
5079
2/2
✓ Branch 0 taken 911872 times.
✓ Branch 1 taken 113984 times.
1025856 for(int32_t q = 0; q < 8; ++q)
5080 {
5081 911872 tempDMap.onmap_initD[q] = 0;
5082
2/2
✓ Branch 0 taken 59271680 times.
✓ Branch 1 taken 911872 times.
60183552 for(int32_t w = 0; w < 65; ++w)
5083 {
5084 59271680 tempDMap.onmap_initD_label[q][w] = 0;
5085 59271680 }
5086 911872 }
5087 }
5088
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 113984 times.
330560 if(s_version >= 16)
5089 {
5090
2/4
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
216576 if(!p_igetw(&tempDMap.mirrorDMap,f))
5091 {
5092 return qe_invalid;
5093 }
5094 216576 }
5095 else
5096 {
5097 113984 tempDMap.mirrorDMap = -1;
5098 }
5099
5100
2/2
✓ Branch 0 taken 123200 times.
✓ Branch 1 taken 207360 times.
330560 if (s_version >= 17)
5101 {
5102 // Reserved for z3.
5103 207360 }
5104
5105 // Enhanced music loop points
5106
2/2
✓ Branch 0 taken 207360 times.
✓ Branch 1 taken 123200 times.
330560 if (s_version >= 18)
5107 {
5108
2/4
✓ Branch 0 taken 207360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207360 times.
✗ Branch 3 not taken.
207360 if (!p_igetl(&tempDMap.tmusic_loop_start, f))
5109 {
5110 return qe_invalid;
5111 }
5112
2/4
✓ Branch 0 taken 207360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207360 times.
✗ Branch 3 not taken.
207360 if (!p_igetl(&tempDMap.tmusic_loop_end, f))
5113 {
5114 return qe_invalid;
5115 }
5116
2/4
✓ Branch 0 taken 207360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207360 times.
✗ Branch 3 not taken.
207360 if (!p_igetl(&tempDMap.tmusic_xfade_in, f))
5117 {
5118 return qe_invalid;
5119 }
5120
2/4
✓ Branch 0 taken 207360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207360 times.
✗ Branch 3 not taken.
207360 if (!p_igetl(&tempDMap.tmusic_xfade_out, f))
5121 {
5122 return qe_invalid;
5123 }
5124 207360 }
5125 else
5126 {
5127 123200 tempDMap.tmusic_loop_start = 0;
5128 123200 tempDMap.tmusic_loop_end = 0;
5129 123200 tempDMap.tmusic_xfade_in = 0;
5130 123200 tempDMap.tmusic_xfade_out = 0;
5131 }
5132
5133
2/2
✓ Branch 0 taken 207360 times.
✓ Branch 1 taken 123200 times.
330560 if(s_version >= 19)
5134
2/4
✓ Branch 0 taken 207360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207360 times.
✗ Branch 3 not taken.
207360 if(!p_getc(&tempDMap.overlay_subscreen, f))
5135 return qe_invalid;
5136
5137
2/2
✓ Branch 0 taken 207360 times.
✓ Branch 1 taken 123200 times.
330560 if (s_version >= 20)
5138 {
5139
2/4
✓ Branch 0 taken 207360 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 207360 times.
✗ Branch 3 not taken.
207360 if (!p_igetl(&tempDMap.intro_string_id, f))
5140 return qe_invalid;
5141 207360 }
5142 else
5143 123200 tempDMap.intro_string_id = 0;
5144
5145 // Reserved for z3.
5146
2/2
✓ Branch 0 taken 123200 times.
✓ Branch 1 taken 207360 times.
330560 if(s_version >= 21)
5147 {
5148
2/2
✓ Branch 0 taken 1658880 times.
✓ Branch 1 taken 207360 times.
1866240 for(int32_t j=0; j<8; j++)
5149 {
5150
2/2
✓ Branch 0 taken 13271040 times.
✓ Branch 1 taken 1658880 times.
14929920 for(int32_t k=0; k<8; k++)
5151 {
5152 char c;
5153
2/4
✓ Branch 0 taken 13271040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13271040 times.
✗ Branch 3 not taken.
13271040 if(!p_getc(&c,f))
5154 {
5155 return qe_invalid;
5156 }
5157 13271040 }
5158 1658880 }
5159 207360 }
5160
5161
2/2
✓ Branch 0 taken 330304 times.
✓ Branch 1 taken 256 times.
330560 if (!should_skip)
5162 {
5163
1/2
✓ Branch 0 taken 330304 times.
✗ Branch 1 not taken.
330304 if(loading_tileset_flags & TILESET_CLEARMAPS)
5164 tempDMap.map = 0;
5165
1/2
✓ Branch 0 taken 330304 times.
✗ Branch 1 not taken.
330304 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
5166 {
5167 tempDMap.script = 0;
5168 for(int q = 0; q < 8; ++q)
5169 tempDMap.initD[q] = 0;
5170 }
5171
1/2
✓ Branch 0 taken 330304 times.
✗ Branch 1 not taken.
330304 DMaps[i] = tempDMap;
5172 330304 }
5173 330560 }
5174
5175 695 return 0;
5176 6839 }
5177
5178 612 int32_t readmisccolors(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5179 {
5180 //these are here to bypass compiler warnings about unused arguments
5181 612 Header=Header;
5182
5183 miscQdata temp_misc;
5184 612 word s_version=0, s_cversion=0;
5185 612 int32_t tempsize=0;
5186 word dummyw;
5187
5188 612 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5189
5190 //section version info
5191
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(!p_igetw(&s_version,f))
5192 {
5193 return qe_invalid;
5194 }
5195
5196 612 FFCore.quest_format[vColours] = s_version;
5197
5198 612 al_trace("Misc Colours section version: %d\n", s_version);
5199
5200
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&s_cversion,f))
5201 {
5202 return qe_invalid;
5203 }
5204
5205
5206 //section size
5207
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetl(&tempsize,f))
5208 {
5209 return qe_invalid;
5210 }
5211
5212 //finally... section data
5213 612 readsize=0;
5214
5215
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.text,f))
5216 {
5217 return qe_invalid;
5218 }
5219
5220
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.caption,f))
5221 {
5222 return qe_invalid;
5223 }
5224
5225
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.overw_bg,f))
5226 {
5227 return qe_invalid;
5228 }
5229
5230
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5231 {
5232 return qe_invalid;
5233 }
5234
5235
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5236 {
5237 return qe_invalid;
5238 }
5239
5240
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.cave_fg,f))
5241 {
5242 return qe_invalid;
5243 }
5244
5245
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.bs_dk,f))
5246 {
5247 return qe_invalid;
5248 }
5249
5250
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.bs_goal,f))
5251 {
5252 return qe_invalid;
5253 }
5254
5255
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.compass_lt,f))
5256 {
5257 return qe_invalid;
5258 }
5259
5260
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.compass_dk,f))
5261 {
5262 return qe_invalid;
5263 }
5264
5265
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5266 {
5267 return qe_invalid;
5268 }
5269
5270
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.triframe_color,f))
5271 {
5272 return qe_invalid;
5273 }
5274
5275
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.hero_dot,f))
5276 {
5277 return qe_invalid;
5278 }
5279
5280
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5281 {
5282 return qe_invalid;
5283 }
5284
5285
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5286 {
5287 return qe_invalid;
5288 }
5289
5290
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5291 {
5292 return qe_invalid;
5293 }
5294
5295
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5296 {
5297 return qe_invalid;
5298 }
5299
5300
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5301 {
5302 return qe_invalid;
5303 }
5304
5305
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5306 {
5307 return qe_invalid;
5308 }
5309
5310
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5311 {
5312 return qe_invalid;
5313 }
5314
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 189 times.
612 if(s_version < 4)
5315 {
5316
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5317 return qe_invalid;
5318 189 temp_misc.colors.triforce_tile = dummyw;
5319
5320
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5321 return qe_invalid;
5322 189 temp_misc.colors.triframe_tile = dummyw;
5323
5324
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5325 return qe_invalid;
5326 189 temp_misc.colors.overworld_map_tile = dummyw;
5327
5328
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5329 return qe_invalid;
5330 189 temp_misc.colors.dungeon_map_tile = dummyw;
5331
5332
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5333 return qe_invalid;
5334 189 temp_misc.colors.blueframe_tile = dummyw;
5335
5336
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&dummyw,f))
5337 return qe_invalid;
5338 189 temp_misc.colors.HCpieces_tile = dummyw;
5339 189 }
5340
5341
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
5342 {
5343 return qe_invalid;
5344 }
5345
5346
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
5347 {
5348 return qe_invalid;
5349 }
5350
5351
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(s_version < 2)
5352 {
5353 temp_misc.colors.msgtext = 0x01;
5354 }
5355 else
5356 {
5357
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_getc(&temp_misc.colors.msgtext, f))
5358 {
5359 return qe_invalid;
5360 }
5361 }
5362
5363
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if ( s_version >= 3 ) //expanded tile pages to 825
5364 {
5365
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&temp_misc.colors.triforce_tile,f))
5366 {
5367 return qe_invalid;
5368 }
5369
5370
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&temp_misc.colors.triframe_tile,f))
5371 {
5372 return qe_invalid;
5373 }
5374
5375
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&temp_misc.colors.overworld_map_tile,f))
5376 {
5377 return qe_invalid;
5378 }
5379
5380
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&temp_misc.colors.dungeon_map_tile,f))
5381 {
5382 return qe_invalid;
5383 }
5384
5385
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&temp_misc.colors.blueframe_tile,f))
5386 {
5387 return qe_invalid;
5388 }
5389
5390
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(!p_igetl(&temp_misc.colors.HCpieces_tile,f))
5391 {
5392 return qe_invalid;
5393 }
5394 423 }
5395
5396 612 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5397
5398 612 return 0;
5399 612 }
5400
5401 612 int32_t readgameicons(PACKFILE *f, zquestheader *, miscQdata *Misc)
5402 {
5403 miscQdata temp_misc;
5404 612 word s_version=0, s_cversion=0;
5405 byte icons;
5406 612 int32_t tempsize=0;
5407
5408 612 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5409
5410 //section version info
5411
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(!p_igetw(&s_version,f))
5412 {
5413 return qe_invalid;
5414 }
5415
5416 612 FFCore.quest_format[vIcons] = s_version;
5417
5418
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&s_cversion,f))
5419 {
5420 return qe_invalid;
5421 }
5422
5423
5424 //section size
5425
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetl(&tempsize,f))
5426 {
5427 return qe_invalid;
5428 }
5429
5430 //finally... section data
5431 612 readsize=0;
5432
5433 612 icons=4;
5434
5435
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 189 times.
612 if ( s_version >= 10 )
5436 {
5437
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<icons; i++)
5438 {
5439
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_igetl(&temp_misc.icons[i],f))
5440 {
5441 return qe_invalid;
5442 }
5443 1692 }
5444 423 }
5445 else
5446 {
5447
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<icons; i++)
5448 {
5449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 756 times.
756 if(!p_igetw(&temp_misc.icons[i],f))
5450 {
5451 return qe_invalid;
5452 }
5453 756 }
5454 }
5455
5456 612 memcpy(Misc, &temp_misc, sizeof(temp_misc));
5457
5458 612 return 0;
5459 612 }
5460
5461 695 int32_t readmisc(PACKFILE *f, zquestheader *Header, miscQdata *Misc)
5462 {
5463
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_misc);
5464
5465 695 word maxinfos=256;
5466 695 word maxshops=256;
5467 695 word shops=16, infos=16, warprings=8, palcycles=256, windwarps=9, triforces=8, icons=4;
5468 695 word ponds=16, pondsize=72, expansionsize=98*2;
5469 byte tempbyte, padding;
5470 miscQdata temp_misc;
5471 695 word s_version=0, s_cversion=0;
5472 word swaptmp;
5473 695 int32_t tempsize=0;
5474
5475 695 memcpy(&temp_misc,Misc,sizeof(temp_misc));
5476
5477
2/2
✓ Branch 0 taken 177920 times.
✓ Branch 1 taken 695 times.
178615 for(int32_t i=0; i<maxshops; ++i)
5478 {
5479 177920 memset(&temp_misc.shop, 0, sizeof(shoptype)*256);
5480 177920 }
5481
5482
2/2
✓ Branch 0 taken 177920 times.
✓ Branch 1 taken 695 times.
178615 for(int32_t i=0; i<maxinfos; ++i)
5483 {
5484 177920 memset(&temp_misc.info, 0, sizeof(infotype)*256);
5485 177920 }
5486
5487
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 if(Header->zelda_version > 0x192)
5488 {
5489 //section version info
5490
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_version,f))
5491 {
5492 return qe_invalid;
5493 }
5494
5495 671 FFCore.quest_format[vMisc] = s_version;
5496
5497
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_cversion,f))
5498 {
5499 return qe_invalid;
5500 }
5501
5502
5503 //section size
5504
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&tempsize,f))
5505 {
5506 return qe_invalid;
5507 }
5508 671 }
5509
5510 //finally... section data
5511 695 readsize=0;
5512
5513 //shops
5514
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 if(Header->zelda_version > 0x192)
5515 {
5516
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&shops,f))
5517 {
5518 return qe_invalid;
5519 }
5520 671 }
5521
5522
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 if (shops > NUM_SHOPS)
5523 {
5524 return qe_invalid;
5525 }
5526
5527
2/2
✓ Branch 0 taken 9971 times.
✓ Branch 1 taken 695 times.
10666 for(int32_t i=0; i<shops; i++)
5528 {
5529
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 8771 times.
9971 if(s_version > 6)
5530 {
5531
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8771 times.
8771 if(!p_getstr(temp_misc.shop[i].name,sizeof(temp_misc.shop[i].name)-1,f))
5532 {
5533 return qe_invalid;
5534 }
5535 8771 }
5536
5537
2/2
✓ Branch 0 taken 29913 times.
✓ Branch 1 taken 9971 times.
39884 for(int32_t j=0; j<3; j++)
5538 {
5539
1/2
✓ Branch 0 taken 29913 times.
✗ Branch 1 not taken.
29913 if(!p_getc(&temp_misc.shop[i].item[j],f))
5540 {
5541 return qe_invalid;
5542 }
5543
5544
2/2
✓ Branch 0 taken 26313 times.
✓ Branch 1 taken 3600 times.
29913 if(s_version < 4)
5545 {
5546 3600 temp_misc.shop[i].hasitem[j] = (temp_misc.shop[i].item[j] == 0) ? 0 : 1;
5547 3600 }
5548 29913 }
5549
5550
2/2
✓ Branch 0 taken 9587 times.
✓ Branch 1 taken 384 times.
9971 if(Header->zelda_version < 0x193)
5551 {
5552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 384 times.
384 if(!p_getc(&tempbyte,f))
5553 {
5554 return qe_invalid;
5555 }
5556 384 }
5557
5558
2/2
✓ Branch 0 taken 29913 times.
✓ Branch 1 taken 9971 times.
39884 for(int32_t j=0; j<3; j++)
5559 {
5560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 29913 times.
29913 if(!p_igetw(&temp_misc.shop[i].price[j],f))
5561 {
5562 return qe_invalid;
5563 }
5564 29913 }
5565
5566
2/2
✓ Branch 0 taken 1200 times.
✓ Branch 1 taken 8771 times.
9971 if(s_version > 3)
5567 {
5568
2/2
✓ Branch 0 taken 26313 times.
✓ Branch 1 taken 8771 times.
35084 for(int32_t j=0; j<3; j++)
5569 {
5570
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26313 times.
26313 if(!p_getc(&temp_misc.shop[i].hasitem[j],f))
5571 return qe_invalid;
5572 26313 }
5573 8771 }
5574
5575 /*
5576 if(s_version < 8)
5577 {
5578 for(int32_t j=0; j<3; j++)
5579 {
5580 (&temp_misc.shop[i].str[j])=0; //initialise.
5581 }
5582 }
5583 */
5584 9971 }
5585
5586 //filter all the 0 items to the end (yeah, bubble sort; sue me)
5587
2/2
✓ Branch 0 taken 177920 times.
✓ Branch 1 taken 695 times.
178615 for(int32_t i=0; i<maxshops; ++i)
5588 {
5589
2/2
✓ Branch 0 taken 355840 times.
✓ Branch 1 taken 177920 times.
533760 for(int32_t j=0; j<3-1; j++)
5590 {
5591
2/2
✓ Branch 0 taken 533760 times.
✓ Branch 1 taken 355840 times.
889600 for(int32_t k=0; k<2-j; k++)
5592 {
5593
2/2
✓ Branch 0 taken 14961 times.
✓ Branch 1 taken 518799 times.
533760 if(temp_misc.shop[i].hasitem[k]==0)
5594 {
5595 518799 swaptmp = temp_misc.shop[i].item[k];
5596 518799 temp_misc.shop[i].item[k] = temp_misc.shop[i].item[k+1];
5597 518799 temp_misc.shop[i].item[k+1] = swaptmp;
5598 518799 swaptmp = temp_misc.shop[i].price[k];
5599 518799 temp_misc.shop[i].price[k] = temp_misc.shop[i].price[k+1];
5600 518799 temp_misc.shop[i].price[k+1] = swaptmp;
5601 518799 swaptmp = temp_misc.shop[i].hasitem[k];
5602 518799 temp_misc.shop[i].hasitem[k] = temp_misc.shop[i].hasitem[k+1];
5603 518799 temp_misc.shop[i].hasitem[k+1] = swaptmp;
5604 518799 }
5605 533760 }
5606 355840 }
5607 177920 }
5608
5609 //infos
5610
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 if(Header->zelda_version > 0x192)
5611 {
5612
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&infos,f))
5613 {
5614 return qe_invalid;
5615 }
5616 671 }
5617
5618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 if (infos > NUM_INFOS)
5619 {
5620 return qe_invalid;
5621 }
5622
5623
5624
2/2
✓ Branch 0 taken 9301 times.
✓ Branch 1 taken 695 times.
9996 for(int32_t i=0; i<infos; i++)
5625 {
5626
2/2
✓ Branch 0 taken 761 times.
✓ Branch 1 taken 8540 times.
9301 if(s_version > 6)
5627 {
5628
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8540 times.
8540 if(!p_getstr(temp_misc.info[i].name,sizeof(temp_misc.info[i].name)-1,f))
5629 {
5630 return qe_invalid;
5631 }
5632 8540 }
5633
5634
2/2
✓ Branch 0 taken 27903 times.
✓ Branch 1 taken 9301 times.
37204 for(int32_t j=0; j<3; j++)
5635 {
5636
3/4
✓ Branch 0 taken 27039 times.
✓ Branch 1 taken 864 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 288 times.
28191 if((Header->zelda_version < 0x192)||
5637
2/2
✓ Branch 0 taken 288 times.
✓ Branch 1 taken 26751 times.
27039 ((Header->zelda_version == 0x192)&&(Header->build<146)))
5638 {
5639
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 864 times.
864 if(!p_getc(&tempbyte,f))
5640 {
5641 return qe_invalid;
5642 }
5643
5644 864 temp_misc.info[i].str[j]=tempbyte;
5645 864 }
5646 else
5647 {
5648
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27039 times.
27039 if(!p_igetw(&temp_misc.info[i].str[j],f))
5649 {
5650 return qe_invalid;
5651 }
5652 }
5653 27903 }
5654
5655
2/2
✓ Branch 0 taken 8917 times.
✓ Branch 1 taken 384 times.
9301 if(Header->zelda_version < 0x193)
5656 {
5657
1/2
✓ Branch 0 taken 384 times.
✗ Branch 1 not taken.
384 if(!p_getc(&tempbyte,f))
5658 {
5659 return qe_invalid;
5660 }
5661 384 }
5662
5663
3/4
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 9205 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96 times.
9301 if((Header->zelda_version == 0x192)&&(Header->build>145))
5664 {
5665
1/2
✓ Branch 0 taken 96 times.
✗ Branch 1 not taken.
96 if(!p_getc(&padding,f))
5666 {
5667 return qe_invalid;
5668 }
5669 96 }
5670
5671
2/2
✓ Branch 0 taken 27903 times.
✓ Branch 1 taken 9301 times.
37204 for(int32_t j=0; j<3; j++)
5672 {
5673
1/2
✓ Branch 0 taken 27903 times.
✗ Branch 1 not taken.
27903 if(!p_igetw(&temp_misc.info[i].price[j],f))
5674 {
5675 return qe_invalid;
5676 }
5677 27903 }
5678 9301 }
5679
5680 //filter all the 0 strings to the end (yeah, bubble sort; sue me)
5681
2/2
✓ Branch 0 taken 177920 times.
✓ Branch 1 taken 695 times.
178615 for(int32_t i=0; i<maxinfos; ++i)
5682 {
5683
2/2
✓ Branch 0 taken 355840 times.
✓ Branch 1 taken 177920 times.
533760 for(int32_t j=0; j<3-1; j++)
5684 {
5685
2/2
✓ Branch 0 taken 533760 times.
✓ Branch 1 taken 355840 times.
889600 for(int32_t k=0; k<2-j; k++)
5686 {
5687
2/2
✓ Branch 0 taken 10537 times.
✓ Branch 1 taken 523223 times.
533760 if(temp_misc.info[i].str[k]==0)
5688 {
5689 523223 swaptmp = temp_misc.info[i].str[k];
5690 523223 temp_misc.info[i].str[k] = temp_misc.info[i].str[k+1];
5691 523223 temp_misc.info[i].str[k+1] = swaptmp;
5692 523223 swaptmp = temp_misc.info[i].price[k];
5693 523223 temp_misc.info[i].price[k] = temp_misc.info[i].price[k+1];
5694 523223 temp_misc.info[i].price[k+1] = swaptmp;
5695 523223 }
5696 533760 }
5697 355840 }
5698 177920 }
5699
5700
5701 //warp rings
5702
2/2
✓ Branch 0 taken 83 times.
✓ Branch 1 taken 612 times.
695 if(s_version > 5)
5703 612 warprings++;
5704
5705
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 if(Header->zelda_version > 0x192)
5706 {
5707
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&warprings,f))
5708 {
5709 return qe_invalid;
5710 }
5711
5712
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 104 times.
671 if (warprings > NUM_WARP_RINGS)
5713 {
5714 // return qe_invalid;
5715 // Note: we can't actually fail here because for some reason, some quest files have more than the max
5716 // number of possible warp rings. Some examples of this are: demosp253.qst, yuurand.qst
5717 // So instead below we disable `keepdata` when reading the bad warp ring data, so no memory is corrupted.
5718 104 }
5719 671 }
5720
5721
2/2
✓ Branch 0 taken 6772 times.
✓ Branch 1 taken 695 times.
7467 for(int32_t i=0; i<warprings; i++)
5722 {
5723 // See above comment on the `warprings` range check.
5724 6772 bool keepdata = i < NUM_WARP_RINGS;
5725
5726
2/2
✓ Branch 0 taken 59828 times.
✓ Branch 1 taken 6772 times.
66600 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5727 {
5728
2/2
✓ Branch 0 taken 8960 times.
✓ Branch 1 taken 50868 times.
59828 if(s_version <= 3)
5729 {
5730
1/2
✓ Branch 0 taken 8960 times.
✗ Branch 1 not taken.
8960 if(!p_getc(&tempbyte,f))
5731 {
5732 return qe_invalid;
5733 }
5734
5735
2/2
✓ Branch 0 taken 3192 times.
✓ Branch 1 taken 5768 times.
8960 if (keepdata)
5736 5768 temp_misc.warp[i].dmap[j]=(word)tempbyte;
5737 8960 }
5738 else
5739 {
5740 word tempword;
5741
1/2
✓ Branch 0 taken 50868 times.
✗ Branch 1 not taken.
50868 if(!p_igetw(&tempword,f))
5742 {
5743 return qe_invalid;
5744 }
5745
5746
2/2
✓ Branch 0 taken 1296 times.
✓ Branch 1 taken 49572 times.
50868 if (keepdata)
5747 49572 temp_misc.warp[i].dmap[j] = tempword;
5748 }
5749 59828 }
5750
5751
2/2
✓ Branch 0 taken 59828 times.
✓ Branch 1 taken 6772 times.
66600 for(int32_t j=0; j<8+((s_version > 5)?1:0); j++)
5752 {
5753
1/2
✓ Branch 0 taken 59828 times.
✗ Branch 1 not taken.
59828 if(!p_getc(&tempbyte,f))
5754 {
5755 return qe_invalid;
5756 }
5757
2/2
✓ Branch 0 taken 4488 times.
✓ Branch 1 taken 55340 times.
59828 if (keepdata)
5758 55340 temp_misc.warp[i].scr[j] = tempbyte;
5759 59828 }
5760
5761
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6772 times.
6772 if(!p_getc(&tempbyte,f))
5762 {
5763 return qe_invalid;
5764 }
5765
2/2
✓ Branch 0 taken 543 times.
✓ Branch 1 taken 6229 times.
6772 if (keepdata)
5766 6229 temp_misc.warp[i].size = tempbyte;
5767
5768
2/2
✓ Branch 0 taken 6580 times.
✓ Branch 1 taken 192 times.
6772 if(Header->zelda_version < 0x193)
5769 {
5770
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 192 times.
192 if(!p_getc(&tempbyte,f))
5771 {
5772 return qe_invalid;
5773 }
5774 192 }
5775 6772 }
5776
5777 //palette cycles
5778
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 if(Header->zelda_version < 0x193) //in 1.93+, palette cycling is saved with the palettes
5779 {
5780
2/2
✓ Branch 0 taken 6144 times.
✓ Branch 1 taken 24 times.
6168 for(int32_t i=0; i<256; i++)
5781 {
5782
2/2
✓ Branch 0 taken 18432 times.
✓ Branch 1 taken 6144 times.
24576 for(int32_t j=0; j<3; j++)
5783 {
5784 18432 temp_misc.cycles[i][j].first=0;
5785 18432 temp_misc.cycles[i][j].count=0;
5786 18432 temp_misc.cycles[i][j].speed=0;
5787 18432 }
5788 6144 }
5789
5790
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
30 if((Header->zelda_version < 0x192)||
5791
1/2
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
6 ((Header->zelda_version == 0x192)&&(Header->build<73)))
5792 {
5793 18 palcycles=16;
5794 18 }
5795
5796
2/2
✓ Branch 0 taken 1824 times.
✓ Branch 1 taken 24 times.
1848 for(int32_t i=0; i<palcycles; i++)
5797 {
5798
2/2
✓ Branch 0 taken 5472 times.
✓ Branch 1 taken 1824 times.
7296 for(int32_t j=0; j<3; j++)
5799 {
5800
1/2
✓ Branch 0 taken 5472 times.
✗ Branch 1 not taken.
5472 if(!p_getc(&temp_misc.cycles[i][j].first,f))
5801 {
5802 return qe_invalid;
5803 }
5804
5805
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].count,f))
5806 {
5807 return qe_invalid;
5808 }
5809
5810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5472 times.
5472 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
5811 {
5812 return qe_invalid;
5813 }
5814 5472 }
5815 1824 }
5816 24 }
5817
5818 //Wind warps are now just another warp ring.
5819
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 83 times.
695 if(s_version <= 5)
5820 {
5821
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 59 times.
83 if(Header->zelda_version > 0x192)
5822 {
5823
1/2
✓ Branch 0 taken 59 times.
✗ Branch 1 not taken.
59 if(!p_igetw(&windwarps,f))
5824 {
5825 return qe_invalid;
5826 }
5827 59 }
5828
5829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 83 times.
83 if (windwarps > NUM_WARP_RINGS)
5830 {
5831 return qe_invalid;
5832 }
5833
5834
2/2
✓ Branch 0 taken 665 times.
✓ Branch 1 taken 83 times.
748 for(int32_t i=0; i<windwarps; i++)
5835 {
5836
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version <= 3)
5837 {
5838
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&tempbyte,f))
5839 {
5840 return qe_invalid;
5841 }
5842
5843 665 temp_misc.warp[8].dmap[i]=tempbyte;
5844 665 }
5845 else
5846 {
5847 if(!p_igetw(&temp_misc.warp[8].dmap[i],f))
5848 {
5849 return qe_invalid;
5850 }
5851 }
5852
5853
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(!p_getc(&temp_misc.warp[8].scr[i],f))
5854 {
5855 return qe_invalid;
5856 }
5857
5858 665 temp_misc.warp[8].size = 9;
5859
5860
1/2
✓ Branch 0 taken 665 times.
✗ Branch 1 not taken.
665 if(s_version == 5)
5861 {
5862 if(!p_getc(&tempbyte,f))
5863 {
5864 return qe_invalid;
5865 }
5866 }
5867 665 }
5868 83 }
5869
5870
5871 //triforce pieces
5872
2/2
✓ Branch 0 taken 5560 times.
✓ Branch 1 taken 695 times.
6255 for(int32_t i=0; i<triforces; i++)
5873 {
5874
1/2
✓ Branch 0 taken 5560 times.
✗ Branch 1 not taken.
5560 if(!p_getc(&temp_misc.triforce[i],f))
5875 {
5876 return qe_invalid;
5877 }
5878 5560 }
5879
5880 //misc color data
5881
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 83 times.
695 if(s_version<3)
5882 {
5883
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.text,f))
5884 {
5885 return qe_invalid;
5886 }
5887
5888
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.caption,f))
5889 {
5890 return qe_invalid;
5891 }
5892
5893
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overw_bg,f))
5894 {
5895 return qe_invalid;
5896 }
5897
5898
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_bg,f))
5899 {
5900 return qe_invalid;
5901 }
5902
5903
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dngn_fg,f))
5904 {
5905 return qe_invalid;
5906 }
5907
5908
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.cave_fg,f))
5909 {
5910 return qe_invalid;
5911 }
5912
5913
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_dk,f))
5914 {
5915 return qe_invalid;
5916 }
5917
5918
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bs_goal,f))
5919 {
5920 return qe_invalid;
5921 }
5922
5923
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_lt,f))
5924 {
5925 return qe_invalid;
5926 }
5927
5928
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.compass_dk,f))
5929 {
5930 return qe_invalid;
5931 }
5932
5933
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.subscr_bg,f))
5934 {
5935 return qe_invalid;
5936 }
5937
5938
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_color,f))
5939 {
5940 return qe_invalid;
5941 }
5942
5943
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.hero_dot,f))
5944 {
5945 return qe_invalid;
5946 }
5947
5948
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_bg,f))
5949 {
5950 return qe_invalid;
5951 }
5952
5953
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.bmap_fg,f))
5954 {
5955 return qe_invalid;
5956 }
5957
5958
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triforce_cset,f))
5959 {
5960 return qe_invalid;
5961 }
5962
5963
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.triframe_cset,f))
5964 {
5965 return qe_invalid;
5966 }
5967
5968
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.overworld_map_cset,f))
5969 {
5970 return qe_invalid;
5971 }
5972
5973
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.dungeon_map_cset,f))
5974 {
5975 return qe_invalid;
5976 }
5977
5978
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.blueframe_cset,f))
5979 {
5980 return qe_invalid;
5981 }
5982
5983
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triforce_tile,f))
5984 {
5985 return qe_invalid;
5986 }
5987
5988
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.triframe_tile,f))
5989 {
5990 return qe_invalid;
5991 }
5992
5993
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.overworld_map_tile,f))
5994 {
5995 return qe_invalid;
5996 }
5997
5998
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.dungeon_map_tile,f))
5999 {
6000 return qe_invalid;
6001 }
6002
6003
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.blueframe_tile,f))
6004 {
6005 return qe_invalid;
6006 }
6007
6008
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_igetw(&temp_misc.colors.HCpieces_tile,f))
6009 {
6010 return qe_invalid;
6011 }
6012
6013
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(!p_getc(&temp_misc.colors.HCpieces_cset,f))
6014 {
6015 return qe_invalid;
6016 }
6017
6018 83 temp_misc.colors.msgtext = 0x01;
6019
6020
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 24 times.
83 if(Header->zelda_version < 0x193)
6021 {
6022
2/2
✓ Branch 0 taken 168 times.
✓ Branch 1 taken 24 times.
192 for(int32_t i=0; i<7; i++)
6023 {
6024
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 if(!p_getc(&tempbyte,f))
6025 {
6026 return qe_invalid;
6027 }
6028 168 }
6029 24 }
6030
6031
3/4
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 77 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
83 if((Header->zelda_version == 0x192)&&(Header->build>145))
6032 {
6033
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<256; i++)
6034 {
6035
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1536 times.
1536 if(!p_getc(&tempbyte,f))
6036 {
6037 return qe_invalid;
6038 }
6039 1536 }
6040 6 }
6041
6042
1/2
✓ Branch 0 taken 83 times.
✗ Branch 1 not taken.
83 if(s_version>1)
6043 {
6044 if(!p_getc(&temp_misc.colors.subscr_shadow,f))
6045 {
6046 return qe_invalid;
6047 }
6048 }
6049
6050 //save game icons
6051
3/4
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
89 if((Header->zelda_version < 0x192)||
6052
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 59 times.
65 ((Header->zelda_version == 0x192)&&(Header->build<73)))
6053 {
6054 18 icons=3;
6055 18 }
6056
6057
2/2
✓ Branch 0 taken 314 times.
✓ Branch 1 taken 83 times.
397 for(int32_t i=0; i<icons; i++)
6058 {
6059
1/2
✓ Branch 0 taken 314 times.
✗ Branch 1 not taken.
314 if(!p_igetw(&temp_misc.icons[i],f))
6060 {
6061 return qe_invalid;
6062 }
6063 314 }
6064 83 }
6065
6066
3/4
✓ Branch 0 taken 677 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
701 if((Header->zelda_version < 0x192)||
6067
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 671 times.
677 ((Header->zelda_version == 0x192)&&(Header->build<30)))
6068 {
6069 18 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6070
6071 18 return 0;
6072 }
6073
6074 //pond information
6075
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 6 times.
677 if(Header->zelda_version < 0x193)
6076 {
6077
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<146))
6078 {
6079 pondsize=25;
6080 }
6081
6082
2/2
✓ Branch 0 taken 96 times.
✓ Branch 1 taken 6 times.
102 for(int32_t i=0; i<ponds; i++)
6083 {
6084
2/2
✓ Branch 0 taken 6912 times.
✓ Branch 1 taken 96 times.
7008 for(int32_t j=0; j<pondsize; j++)
6085 {
6086
1/2
✓ Branch 0 taken 6912 times.
✗ Branch 1 not taken.
6912 if(!p_getc(&tempbyte,f))
6087 {
6088 return qe_invalid;
6089
6090 }
6091 6912 }
6092 96 }
6093 6 }
6094
6095 //end string
6096
2/4
✓ Branch 0 taken 677 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 6 times.
683 if((Header->zelda_version < 0x192)||
6097
2/2
✓ Branch 0 taken 6 times.
✓ Branch 1 taken 671 times.
677 ((Header->zelda_version == 0x192)&&(Header->build<146)))
6098 {
6099 if(!p_getc(&tempbyte,f))
6100 {
6101 return qe_invalid;
6102 }
6103
6104 temp_misc.endstring=tempbyte;
6105
6106 if(!p_getc(&tempbyte,f))
6107 {
6108 return qe_invalid;
6109 }
6110 }
6111 else
6112 {
6113
1/2
✓ Branch 0 taken 677 times.
✗ Branch 1 not taken.
677 if(!p_igetw(&temp_misc.endstring,f))
6114 {
6115 return qe_invalid;
6116 }
6117 }
6118
6119 //expansion
6120
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 6 times.
677 if(Header->zelda_version < 0x193)
6121 {
6122
2/4
✓ Branch 0 taken 6 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✗ Branch 3 not taken.
6 if((Header->zelda_version == 0x192)&&(Header->build<73))
6123 {
6124 expansionsize=99*2;
6125 }
6126
6127
2/2
✓ Branch 0 taken 1176 times.
✓ Branch 1 taken 6 times.
1182 for(int32_t i=0; i<expansionsize; i++)
6128 {
6129
1/2
✓ Branch 0 taken 1176 times.
✗ Branch 1 not taken.
1176 if(!p_getc(&tempbyte,f))
6130 {
6131 return qe_invalid;
6132 }
6133 1176 }
6134 6 }
6135 //shops v8
6136
6137
6138
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 423 times.
677 if(s_version >= 8)
6139 {
6140
2/2
✓ Branch 0 taken 6592 times.
✓ Branch 1 taken 423 times.
7015 for(int32_t i=0; i<shops; i++)
6141 {
6142
2/2
✓ Branch 0 taken 19776 times.
✓ Branch 1 taken 6592 times.
26368 for(int32_t j=0; j<3; j++)
6143 {
6144
1/2
✓ Branch 0 taken 19776 times.
✗ Branch 1 not taken.
19776 if(!p_igetw(&temp_misc.shop[i].str[j],f))
6145 return qe_invalid;
6146 19776 }
6147 6592 }
6148 423 }
6149
6150 677 memset(&temp_misc.questmisc, 0, sizeof(int32_t)*32);
6151 677 memset(&temp_misc.questmisc_strings, 0, sizeof(char)*4096);
6152 677 memset(&temp_misc.zscript_last_compiled_version, 0, sizeof(int32_t));
6153
6154 //v9 includes quest misc[32]
6155
2/2
✓ Branch 0 taken 254 times.
✓ Branch 1 taken 423 times.
677 if(s_version >= 9)
6156 {
6157
2/2
✓ Branch 0 taken 13536 times.
✓ Branch 1 taken 423 times.
13959 for ( int32_t q = 0; q < 32; q++ )
6158 {
6159
1/2
✓ Branch 0 taken 13536 times.
✗ Branch 1 not taken.
13536 if(!p_igetl(&temp_misc.questmisc[q],f))
6160 return qe_invalid;
6161 13536 }
6162
2/2
✓ Branch 0 taken 13536 times.
✓ Branch 1 taken 423 times.
13959 for ( int32_t q = 0; q < 32; q++ )
6163 {
6164
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 13536 times.
1746144 for ( int32_t j = 0; j < 128; j++ )
6165
1/2
✓ Branch 0 taken 1732608 times.
✗ Branch 1 not taken.
1732608 if(!p_getc(&temp_misc.questmisc_strings[q][j],f))
6166 return qe_invalid;
6167 13536 }
6168 423 }
6169
6170
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 254 times.
677 if(s_version >= 11 )
6171 {
6172
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&temp_misc.zscript_last_compiled_version,f))
6173 return qe_invalid;
6174 423 }
6175
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 254 times.
254 else if(s_version < 11 )
6176 {
6177 254 temp_misc.zscript_last_compiled_version = -1;
6178 254 }
6179
6180 677 FFCore.quest_format[vLastCompile] = temp_misc.zscript_last_compiled_version;
6181
6182
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 254 times.
677 if(s_version >= 12)
6183 {
6184 byte spr;
6185
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 423 times.
108711 for(int32_t q = 0; q < sprMAX; ++q)
6186 {
6187
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_getc(&spr,f))
6188 return qe_invalid;
6189 108288 temp_misc.sprites[q] = spr;
6190 108288 }
6191 423 }
6192 else
6193 {
6194 254 memset(&(temp_misc.sprites), 0, sizeof(temp_misc.sprites));
6195 //temp_misc.sprites[sprFALL] = ;
6196 }
6197
6198
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 254 times.
677 if(s_version >= 13)
6199 {
6200
2/2
✓ Branch 0 taken 27072 times.
✓ Branch 1 taken 423 times.
27495 for(size_t q = 0; q < 64; ++q)
6201 {
6202 27072 bottletype* bt = &(temp_misc.bottle_types[q]);
6203
1/2
✓ Branch 0 taken 27072 times.
✗ Branch 1 not taken.
27072 if (!p_getstr(bt->name, sizeof(bt->name)-1, f))
6204 return qe_invalid;
6205
2/2
✓ Branch 0 taken 81216 times.
✓ Branch 1 taken 27072 times.
108288 for(size_t j = 0; j < 3; ++j)
6206 {
6207
1/2
✓ Branch 0 taken 81216 times.
✗ Branch 1 not taken.
81216 if (!p_getc(&(bt->counter[j]), f))
6208 return qe_invalid;
6209
1/2
✓ Branch 0 taken 81216 times.
✗ Branch 1 not taken.
81216 if (!p_igetw(&(bt->amount[j]), f))
6210 return qe_invalid;
6211 81216 }
6212
1/2
✓ Branch 0 taken 27072 times.
✗ Branch 1 not taken.
27072 if (!p_getc(&(bt->flags), f))
6213 return qe_invalid;
6214
1/2
✓ Branch 0 taken 27072 times.
✗ Branch 1 not taken.
27072 if (!p_getc(&(bt->next_type), f))
6215 return qe_invalid;
6216 27072 }
6217
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 423 times.
108711 for(size_t q = 0; q < 256; ++q)
6218 {
6219 108288 bottleshoptype* bst = &(temp_misc.bottle_shop_types[q]);
6220
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if (!pfread(bst->name, sizeof(bst->name)-1, f))
6221 return qe_invalid;
6222
2/2
✓ Branch 0 taken 324864 times.
✓ Branch 1 taken 108288 times.
433152 for(size_t j = 0; j < 3; ++j)
6223 {
6224
1/2
✓ Branch 0 taken 324864 times.
✗ Branch 1 not taken.
324864 if (!p_getc(&(bst->fill[j]), f))
6225 return qe_invalid;
6226
1/2
✓ Branch 0 taken 324864 times.
✗ Branch 1 not taken.
324864 if (!p_igetw(&(bst->comb[j]), f))
6227 return qe_invalid;
6228
1/2
✓ Branch 0 taken 324864 times.
✗ Branch 1 not taken.
324864 if (!p_getc(&(bst->cset[j]), f))
6229 return qe_invalid;
6230
1/2
✓ Branch 0 taken 324864 times.
✗ Branch 1 not taken.
324864 if (!p_igetw(&(bst->price[j]), f))
6231 return qe_invalid;
6232
1/2
✓ Branch 0 taken 324864 times.
✗ Branch 1 not taken.
324864 if (!p_igetw(&(bst->str[j]), f))
6233 return qe_invalid;
6234 324864 }
6235 108288 }
6236 423 }
6237 else
6238 {
6239
2/2
✓ Branch 0 taken 16256 times.
✓ Branch 1 taken 254 times.
16510 for(size_t q = 0; q < 64; ++q)
6240 16256 temp_misc.bottle_types[q].clear();
6241
2/2
✓ Branch 0 taken 65024 times.
✓ Branch 1 taken 254 times.
65278 for(size_t q = 0; q < 256; ++q)
6242 65024 temp_misc.bottle_shop_types[q].clear();
6243 }
6244
6245
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 254 times.
677 if(s_version >= 14)
6246 {
6247 byte msfx;
6248
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 423 times.
108711 for(int32_t q = 0; q < sfxMAX; ++q)
6249 {
6250
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_getc(&msfx,f))
6251 return qe_invalid;
6252 108288 temp_misc.miscsfx[q] = msfx;
6253 108288 }
6254 423 }
6255 else
6256 {
6257 254 memset(&(temp_misc.miscsfx), 0, sizeof(temp_misc.miscsfx));
6258 254 temp_misc.miscsfx[sfxBUSHGRASS] = WAV_ZN1GRASSCUT;
6259 254 temp_misc.miscsfx[sfxLOWHEART] = WAV_ER;
6260 }
6261
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 254 times.
677 if(s_version < 15)
6262 {
6263 254 temp_misc.miscsfx[sfxHURTPLAYER] = WAV_OUCH;
6264 254 temp_misc.miscsfx[sfxHAMMERPOUND] = WAV_ZN1HAMMERPOST;
6265 254 temp_misc.miscsfx[sfxSUBSCR_ITEM_ASSIGN] = WAV_PLACE;
6266 254 temp_misc.miscsfx[sfxSUBSCR_CURSOR_MOVE] = WAV_CHIME;
6267 254 temp_misc.miscsfx[sfxREFILL] = WAV_MSG;
6268 254 temp_misc.miscsfx[sfxDRAIN] = WAV_MSG;
6269 254 }
6270
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 272 times.
677 if(s_version < 16)
6271 {
6272 272 temp_misc.miscsfx[sfxTAP] = WAV_ZN1TAP;
6273 272 temp_misc.miscsfx[sfxTAP_HOLLOW] = WAV_ZN1TAP2;
6274 272 }
6275
6276
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 676 times.
677 if (!should_skip)
6277 676 memcpy(Misc, &temp_misc, sizeof(temp_misc));
6278
6279 677 return 0;
6280 695 }
6281
6282 extern char *item_string[MAXITEMS];
6283 extern const char *old_item_string[iLast];
6284 extern char *weapon_string[MAXWPNS];
6285 extern const char *old_weapon_string[wLast];
6286
6287 695 int32_t readitems(PACKFILE *f, word version, word build)
6288 {
6289
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_items);
6290
6291 byte padding;
6292 int32_t dummy;
6293 695 word items_to_read=MAXITEMS;
6294 itemdata tempitem;
6295 695 word s_version=0, s_cversion=0;
6296 word dummy_word;
6297
6298
2/2
✓ Branch 0 taken 689 times.
✓ Branch 1 taken 6 times.
695 if(version < 0x186)
6299 {
6300 6 items_to_read=64;
6301 6 }
6302
6303
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 if(version > 0x192)
6304 {
6305 671 items_to_read=0;
6306
6307 //section version info
6308
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_version,f))
6309 {
6310 return qe_invalid;
6311 }
6312
6313 671 FFCore.quest_format[vItems] = s_version;
6314
6315
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_cversion,f))
6316 {
6317 return qe_invalid;
6318 }
6319
6320 //section size
6321
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&dummy,f))
6322 {
6323 return qe_invalid;
6324 }
6325
6326 //finally... section data
6327
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&items_to_read,f))
6328 {
6329 return qe_invalid;
6330 }
6331
6332
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if (items_to_read > MAXITEMS)
6333 {
6334 return qe_invalid;
6335 }
6336 671 }
6337
6338
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 83 times.
695 if(s_version>1)
6339 {
6340
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 612 times.
157284 for(int32_t i=0; i<items_to_read; i++)
6341 {
6342 char tempname[64];
6343
6344
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!pfread(tempname, 64, f))
6345 {
6346 return qe_invalid;
6347 }
6348
6349 156672 item_string[i][0] = '\0';
6350 156672 strncat(item_string[i], tempname, 64 - 1);
6351 156672 }
6352 612 }
6353
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
6354 {
6355
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
6356 {
6357 20992 reset_itemname(i);
6358 20992 }
6359 82 }
6360
6361
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 694 times.
695 if (!should_skip)
6362
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<MAXITEMS; i++)
6363 {
6364 177664 itemdata& id = itemsbuf[i];
6365 177664 memset(&id, 0, sizeof(itemdata));
6366 177664 id.count=-1;
6367 177664 id.playsound=WAV_SCALE;
6368 177664 reset_itembuf(&id,i);
6369 178358 }
6370
6371
2/2
✓ Branch 0 taken 165794 times.
✓ Branch 1 taken 695 times.
166489 for(int32_t i=0; i<items_to_read; i++)
6372 {
6373 165794 memset(&tempitem, 0, sizeof(itemdata));
6374 165794 reset_itembuf(&tempitem,i);
6375
6376
6377
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 57506 times.
165794 if ( s_version > 35 ) //expanded tiles
6378 {
6379
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.tile,f))
6380 {
6381 return qe_invalid;
6382 }
6383 108288 }
6384 else
6385 {
6386
1/2
✓ Branch 0 taken 57506 times.
✗ Branch 1 not taken.
57506 if(!p_igetw(&tempitem.tile,f))
6387 {
6388 return qe_invalid;
6389 }
6390 }
6391
6392
1/2
✓ Branch 0 taken 165794 times.
✗ Branch 1 not taken.
165794 if(!p_getc(&tempitem.misc_flags,f))
6393 {
6394 return qe_invalid;
6395 }
6396
6397
1/2
✓ Branch 0 taken 165794 times.
✗ Branch 1 not taken.
165794 if(!p_getc(&tempitem.csets,f))
6398 {
6399 return qe_invalid;
6400 }
6401
6402
1/2
✓ Branch 0 taken 165794 times.
✗ Branch 1 not taken.
165794 if(!p_getc(&tempitem.frames,f))
6403 {
6404 return qe_invalid;
6405 }
6406
6407
1/2
✓ Branch 0 taken 165794 times.
✗ Branch 1 not taken.
165794 if(!p_getc(&tempitem.speed,f))
6408 {
6409 return qe_invalid;
6410 }
6411
6412
1/2
✓ Branch 0 taken 165794 times.
✗ Branch 1 not taken.
165794 if(!p_getc(&tempitem.delay,f))
6413 {
6414 return qe_invalid;
6415 }
6416
6417
2/2
✓ Branch 0 taken 160802 times.
✓ Branch 1 taken 4992 times.
165794 if(version < 0x193)
6418 {
6419
1/2
✓ Branch 0 taken 4992 times.
✗ Branch 1 not taken.
4992 if(!p_getc(&padding,f))
6420 {
6421 return qe_invalid;
6422 }
6423
6424
4/6
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 3456 times.
✓ Branch 2 taken 1536 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1536 times.
✗ Branch 5 not taken.
4992 if((version < 0x192)||((version == 0x192)&&(build<186)))
6425 {
6426
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 4736 times.
4992 if (should_skip)
6427 256 continue;
6428
6429
3/3
✓ Branch 0 taken 4690 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
4736 switch(i)
6430 {
6431 case iShield:
6432 23 tempitem.ltm=get_qr(qr_BSZELDA)?-12:10;
6433 23 break;
6434
6435 case iMShield:
6436 23 tempitem.ltm=get_qr(qr_BSZELDA)?-6:-10;
6437 23 break;
6438
6439 default:
6440 4690 tempitem.ltm=0;
6441 4690 break;
6442 }
6443
6444 4736 tempitem.count=-1;
6445 4736 tempitem.flags=item_none;
6446 4736 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=
6447 4736 tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
6448 4736 tempitem.family=0xFF;
6449 4736 tempitem.playsound=WAV_SCALE;
6450 4736 reset_itembuf(&tempitem,i);
6451
6452 4736 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
6453
6454 4736 continue;
6455 }
6456 }
6457
6458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160802 times.
160802 if(!p_igetl(&tempitem.ltm,f))
6459 {
6460 return qe_invalid;
6461 }
6462
6463
1/2
✓ Branch 0 taken 160802 times.
✗ Branch 1 not taken.
160802 if(version < 0x193)
6464 {
6465 for(int32_t q=0; q<12; q++)
6466 {
6467 if(!p_getc(&padding,f))
6468 {
6469 return qe_invalid;
6470 }
6471 }
6472 }
6473
6474
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 4130 times.
160802 if(s_version>1)
6475 {
6476
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 48384 times.
156672 if ( s_version >= 31 )
6477 {
6478
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.family,f))
6479 {
6480 return qe_invalid;
6481 }
6482 108288 }
6483 else
6484 {
6485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48384 times.
48384 if(!p_getc(&tempitem.family,f))
6486 {
6487 return qe_invalid;
6488 }
6489 }
6490
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(s_version < 16)
6491 if(tempitem.family == 0xFF)
6492 tempitem.family = itype_misc;
6493
6494
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_getc(&tempitem.fam_type,f))
6495 {
6496 return qe_invalid;
6497 }
6498
6499
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(s_version>5)
6500 {
6501
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 48384 times.
156672 if(s_version>=31)
6502 {
6503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.power,f))
6504 {
6505 return qe_invalid;
6506 }
6507 108288 }
6508 else
6509 {
6510
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48384 times.
48384 if(!p_getc(&tempitem.power,f))
6511 {
6512 return qe_invalid;
6513 }
6514 }
6515
6516 //converted flags from 16b to 32b -Z
6517
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version < 41 )
6518 {
6519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 48384 times.
48384 if(!p_igetw(&tempitem.flags,f))
6520 {
6521 return qe_invalid;
6522 }
6523 48384 }
6524 else
6525 {
6526
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.flags,f))
6527 {
6528 return qe_invalid;
6529 }
6530 }
6531 156672 }
6532 else
6533 {
6534 //tempitem.power = tempitem.fam_type;
6535 char tempchar;
6536
6537 if(!p_getc(&tempchar,f))
6538 {
6539 return qe_invalid;
6540 }
6541
6542 if (tempchar) tempitem.flags |= item_gamedata;
6543 }
6544
6545
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_igetw(&tempitem.script,f))
6546 {
6547 return qe_invalid;
6548 }
6549
6550
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(s_version<=3)
6551 {
6552 if(tempitem.script > NUMSCRIPTITEM)
6553 {
6554 tempitem.script = 0;
6555 }
6556 }
6557
6558
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_getc(&tempitem.count,f))
6559 {
6560 return qe_invalid;
6561 }
6562
6563
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_igetw(&tempitem.amount,f))
6564 {
6565 return qe_invalid;
6566 }
6567
6568
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_igetw(&tempitem.collect_script,f))
6569 {
6570 return qe_invalid;
6571 }
6572
6573
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(s_version<=3)
6574 {
6575 if(tempitem.collect_script > NUMSCRIPTITEM)
6576 {
6577 tempitem.collect_script = 0;
6578 }
6579 }
6580
6581
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_igetw(&tempitem.setmax,f))
6582 {
6583 return qe_invalid;
6584 }
6585
6586
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_igetw(&tempitem.max,f))
6587 {
6588 return qe_invalid;
6589 }
6590
6591
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_getc(&tempitem.playsound,f))
6592 {
6593 return qe_invalid;
6594 }
6595
6596
2/2
✓ Branch 0 taken 1253376 times.
✓ Branch 1 taken 156672 times.
1410048 for(int32_t j=0; j<8; j++)
6597 {
6598
1/2
✓ Branch 0 taken 1253376 times.
✗ Branch 1 not taken.
1253376 if(!p_igetl(&tempitem.initiald[j],f))
6599 {
6600 return qe_invalid;
6601 }
6602 1253376 }
6603
6604
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 156672 times.
470016 for(int32_t j=0; j<2; j++)
6605 {
6606
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_getc(&tempitem.initiala[j],f))
6607 {
6608 return qe_invalid;
6609 }
6610 313344 }
6611
6612
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(s_version>4)
6613 {
6614
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(s_version>5)
6615 {
6616
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_getc(&tempitem.wpn,f))
6617 {
6618 return qe_invalid;
6619 }
6620
6621
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_getc(&tempitem.wpn2,f))
6622 {
6623 return qe_invalid;
6624 }
6625
6626
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_getc(&tempitem.wpn3,f))
6627 {
6628 return qe_invalid;
6629 }
6630
6631
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_getc(&tempitem.wpn4,f))
6632 {
6633 return qe_invalid;
6634 }
6635
6636
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(s_version>=15)
6637 {
6638
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_getc(&tempitem.wpn5,f))
6639 {
6640 return qe_invalid;
6641 }
6642
6643
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_getc(&tempitem.wpn6,f))
6644 {
6645 return qe_invalid;
6646 }
6647
6648
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_getc(&tempitem.wpn7,f))
6649 {
6650 return qe_invalid;
6651 }
6652
6653
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_getc(&tempitem.wpn8,f))
6654 {
6655 return qe_invalid;
6656 }
6657
6658
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_getc(&tempitem.wpn9,f))
6659 {
6660 return qe_invalid;
6661 }
6662
6663
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_getc(&tempitem.wpn10,f))
6664 {
6665 return qe_invalid;
6666 }
6667 156672 }
6668
6669
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_getc(&tempitem.pickup_hearts,f))
6670 {
6671 return qe_invalid;
6672 }
6673
6674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(s_version<15)
6675 {
6676 if(!p_igetw(&dummy_word,f))
6677 {
6678 return qe_invalid;
6679 }
6680
6681 tempitem.misc1=dummy_word;
6682
6683 if(!p_igetw(&dummy_word,f))
6684 {
6685 return qe_invalid;
6686 }
6687
6688 tempitem.misc2=dummy_word;
6689 }
6690 else
6691 {
6692
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_igetl(&tempitem.misc1,f))
6693 {
6694 return qe_invalid;
6695 }
6696
6697
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_igetl(&tempitem.misc2,f))
6698 {
6699 return qe_invalid;
6700 }
6701
6702 // Version 24: sh_ice -> sh_script; previously, all shields could block script weapons
6703
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(s_version<24)
6704 {
6705 if(tempitem.family==itype_shield)
6706 {
6707 tempitem.misc1|=sh_script;
6708 }
6709 }
6710 }
6711
6712
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if(s_version < 53)
6713 {
6714 byte tempbyte;
6715
1/2
✓ Branch 0 taken 48384 times.
✗ Branch 1 not taken.
48384 if(!p_getc(&tempbyte,f))
6716 {
6717 return qe_invalid;
6718 }
6719 48384 tempitem.cost_amount[0] = tempbyte;
6720 48384 }
6721 else
6722 {
6723
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 108288 times.
324864 for(auto q = 0; q < 2; ++q)
6724 {
6725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216576 times.
216576 if(!p_igetw(&tempitem.cost_amount[q],f))
6726 {
6727 return qe_invalid;
6728 }
6729 216576 }
6730 }
6731 156672 }
6732 else
6733 {
6734 char tempchar;
6735
6736 if(!p_getc(&tempchar,f))
6737 {
6738 return qe_invalid;
6739 }
6740
6741 if (tempchar) tempitem.flags |= item_edible;
6742 }
6743
6744 // June 2007: more misc. attributes
6745
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(s_version>=12)
6746 {
6747
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(s_version<15)
6748 {
6749 if(!p_igetw(&dummy_word,f))
6750 {
6751 return qe_invalid;
6752 }
6753
6754 tempitem.misc3=dummy_word;
6755
6756 if(!p_igetw(&dummy_word,f))
6757 {
6758 return qe_invalid;
6759 }
6760
6761 tempitem.misc4=dummy_word;
6762 }
6763 else
6764 {
6765
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_igetl(&tempitem.misc3,f))
6766 {
6767 return qe_invalid;
6768 }
6769
6770
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_igetl(&tempitem.misc4,f))
6771 {
6772 return qe_invalid;
6773 }
6774
6775
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_igetl(&tempitem.misc5,f))
6776 {
6777 return qe_invalid;
6778 }
6779
6780
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_igetl(&tempitem.misc6,f))
6781 {
6782 return qe_invalid;
6783 }
6784
6785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_igetl(&tempitem.misc7,f))
6786 {
6787 return qe_invalid;
6788 }
6789
6790
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_igetl(&tempitem.misc8,f))
6791 {
6792 return qe_invalid;
6793 }
6794
6795
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_igetl(&tempitem.misc9,f))
6796 {
6797 return qe_invalid;
6798 }
6799
6800
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!p_igetl(&tempitem.misc10,f))
6801 {
6802 return qe_invalid;
6803 }
6804 }
6805
6806
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156672 times.
156672 if(!p_getc(&tempitem.usesound,f))
6807 {
6808 return qe_invalid;
6809 }
6810
6811
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 48384 times.
156672 if(s_version >= 49)
6812 {
6813
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_getc(&tempitem.usesound2,f))
6814 {
6815 return qe_invalid;
6816 }
6817 108288 }
6818 48384 else tempitem.usesound2 = 0;
6819
6820
3/4
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
✓ Branch 2 taken 48384 times.
✗ Branch 3 not taken.
156672 if(s_version < 50 && tempitem.family == itype_mirror)
6821 {
6822 //Split continue/dmap warp effect/sfx, port for old
6823 tempitem.misc2 = tempitem.misc1;
6824 tempitem.usesound2 = tempitem.usesound;
6825 }
6826 156672 }
6827 156672 }
6828
6829
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 26 ) //! New itemdata vars for weapon editor. -Z
6830 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6831
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_getc(&tempitem.useweapon,f))
6832 {
6833 return qe_invalid;
6834 }
6835
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_getc(&tempitem.usedefence,f))
6836 {
6837 return qe_invalid;
6838 }
6839
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.weaprange,f))
6840 {
6841 return qe_invalid;
6842 }
6843
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.weapduration,f))
6844 {
6845 return qe_invalid;
6846 }
6847
2/2
✓ Branch 0 taken 1082880 times.
✓ Branch 1 taken 108288 times.
1191168 for ( int32_t q = 0; q < ITEM_MOVEMENT_PATTERNS; q++ )
6848 {
6849
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1082880 times.
1082880 if(!p_igetl(&tempitem.weap_pattern[q],f))
6850 {
6851 return qe_invalid;
6852 }
6853 1082880 }
6854 108288 }
6855
6856
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 27 ) //! New itemdata vars for weapon editor. -Z
6857 { // temp.useweapon, temp.usedefence, temp.weaprange, temp.weap_pattern[ITEM_MOVEMENT_PATTERNS]
6858
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.duplicates,f))
6859 {
6860 return qe_invalid;
6861 }
6862
2/2
✓ Branch 0 taken 866304 times.
✓ Branch 1 taken 108288 times.
974592 for ( int32_t q = 0; q < INITIAL_D; q++ )
6863 {
6864
1/2
✓ Branch 0 taken 866304 times.
✗ Branch 1 not taken.
866304 if(!p_igetl(&tempitem.weap_initiald[q],f))
6865 {
6866 return qe_invalid;
6867 }
6868 866304 }
6869
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 108288 times.
324864 for ( int32_t q = 0; q < INITIAL_A; q++ )
6870 {
6871
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_getc(&tempitem.weap_initiala[q],f))
6872 {
6873 return qe_invalid;
6874 }
6875 216576 }
6876
6877
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_getc(&tempitem.drawlayer,f))
6878 {
6879 return qe_invalid;
6880 }
6881
6882
6883
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.hxofs,f))
6884 {
6885 return qe_invalid;
6886 }
6887
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.hyofs,f))
6888 {
6889 return qe_invalid;
6890 }
6891
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.hxsz,f))
6892 {
6893 return qe_invalid;
6894 }
6895
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.hysz,f))
6896 {
6897 return qe_invalid;
6898 }
6899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.hzsz,f))
6900 {
6901 return qe_invalid;
6902 }
6903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.xofs,f))
6904 {
6905 return qe_invalid;
6906 }
6907
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.yofs,f))
6908 {
6909 return qe_invalid;
6910 }
6911
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.weap_hxofs,f))
6912 {
6913 return qe_invalid;
6914 }
6915
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.weap_hyofs,f))
6916 {
6917 return qe_invalid;
6918 }
6919
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.weap_hxsz,f))
6920 {
6921 return qe_invalid;
6922 }
6923
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.weap_hysz,f))
6924 {
6925 return qe_invalid;
6926 }
6927
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.weap_hzsz,f))
6928 {
6929 return qe_invalid;
6930 }
6931
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.weap_xofs,f))
6932 {
6933 return qe_invalid;
6934 }
6935
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.weap_yofs,f))
6936 {
6937 return qe_invalid;
6938 }
6939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetw(&tempitem.weaponscript,f))
6940 {
6941 return qe_invalid;
6942 }
6943
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.wpnsprite,f))
6944 {
6945 return qe_invalid;
6946 }
6947 108288 auto num_cost_tmr = (s_version > 52 ? 2 : 1);
6948
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 108288 times.
324864 for(auto q = 0; q < num_cost_tmr; ++q)
6949 {
6950
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216576 times.
216576 if(!p_igetl(&tempitem.magiccosttimer[q],f))
6951 {
6952 return qe_invalid;
6953 }
6954 216576 }
6955
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 for(auto q = num_cost_tmr; q < 2; ++q)
6956 tempitem.magiccosttimer[q] = 0;
6957 108288 }
6958
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 28 ) //! New itemdata vars for weapon editor. -Z
6959 {
6960 //Item Size FLags, TileWidth, TileHeight
6961
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.overrideFLAGS,f))
6962 {
6963 return qe_invalid;
6964 }
6965
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.tilew,f))
6966 {
6967 return qe_invalid;
6968 }
6969
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.tileh,f))
6970 {
6971 return qe_invalid;
6972 }
6973 108288 }
6974
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 29 ) //! More new vars.
6975 {
6976 //Item Size FLags, TileWidth, TileHeight
6977
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetl(&tempitem.weapoverrideFLAGS,f))
6978 {
6979 return qe_invalid;
6980 }
6981
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.weap_tilew,f))
6982 {
6983 return qe_invalid;
6984 }
6985
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.weap_tileh,f))
6986 {
6987 return qe_invalid;
6988 }
6989 108288 }
6990
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 30 ) //! More new vars.
6991 {
6992 //Pickup Type
6993
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempitem.pickup,f))
6994 {
6995 return qe_invalid;
6996 }
6997 108288 }
6998
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 32 ) //! More new vars.
6999 {
7000 //Pickup Type
7001
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetw(&tempitem.pstring,f))
7002 {
7003 return qe_invalid;
7004 }
7005 108288 }
7006
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 33 ) //! More new vars.
7007 {
7008 //Pickup Type
7009
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(!p_igetw(&tempitem.pickup_string_flags,f))
7010 {
7011 return qe_invalid;
7012 }
7013 108288 }
7014
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 34 ) //! cost counter
7015 {
7016
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 108288 times.
108288 if(s_version < 53)
7017 {
7018 if(!p_getc(&tempitem.cost_counter[0],f))
7019 {
7020 return qe_invalid;
7021 }
7022 }
7023 else
7024 {
7025
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 108288 times.
324864 for(auto q = 0; q < 2; ++q)
7026 {
7027
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_getc(&tempitem.cost_counter[q],f))
7028 {
7029 return qe_invalid;
7030 }
7031 216576 }
7032 }
7033 108288 }
7034
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 44 ) //! sprite scripts
7035 {
7036
2/2
✓ Branch 0 taken 866304 times.
✓ Branch 1 taken 108288 times.
974592 for ( int32_t q = 0; q < 8; q++ )
7037 {
7038
2/2
✓ Branch 0 taken 56309760 times.
✓ Branch 1 taken 866304 times.
57176064 for ( int32_t w = 0; w < 65; w++ )
7039 {
7040
1/2
✓ Branch 0 taken 56309760 times.
✗ Branch 1 not taken.
56309760 if(!p_getc(&(tempitem.initD_label[q][w]),f))
7041 {
7042 return qe_invalid;
7043 }
7044 56309760 }
7045
2/2
✓ Branch 0 taken 56309760 times.
✓ Branch 1 taken 866304 times.
57176064 for ( int32_t w = 0; w < 65; w++ )
7046 {
7047
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56309760 times.
56309760 if(!p_getc(&(tempitem.weapon_initD_label[q][w]),f))
7048 {
7049 return qe_invalid;
7050 }
7051 56309760 }
7052
2/2
✓ Branch 0 taken 56309760 times.
✓ Branch 1 taken 866304 times.
57176064 for ( int32_t w = 0; w < 65; w++ )
7053 {
7054
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 56309760 times.
56309760 if(!p_getc(&(tempitem.sprite_initD_label[q][w]),f))
7055 {
7056 return qe_invalid;
7057 }
7058 56309760 }
7059
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 866304 times.
866304 if(!p_igetl(&(tempitem.sprite_initiald[q]),f))
7060 {
7061 return qe_invalid;
7062 }
7063
7064 866304 }
7065
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 108288 times.
324864 for ( int32_t q = 0; q < 2; q++ )
7066 {
7067
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 216576 times.
216576 if(!p_getc(&(tempitem.sprite_initiala[q]),f))
7068 {
7069 return qe_invalid;
7070 }
7071 216576 }
7072 //Pickup Type
7073
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetw(&tempitem.sprite_script,f))
7074 {
7075 return qe_invalid;
7076 }
7077 108288 }
7078
2/2
✓ Branch 0 taken 48384 times.
✓ Branch 1 taken 108288 times.
156672 if ( s_version >= 48 ) //! pickup flags
7079 {
7080
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_getc(&(tempitem.pickupflag),f))
7081 {
7082 return qe_invalid;
7083 }
7084 108288 }
7085
2/2
✓ Branch 0 taken 51712 times.
✓ Branch 1 taken 104960 times.
156672 if ( s_version >= 57 )
7086 {
7087 104960 std::string str;
7088
2/4
✗ Branch 0 not taken.
✓ Branch 1 taken 104960 times.
✓ Branch 2 taken 104960 times.
✗ Branch 3 not taken.
104960 if(!p_getcstr(&str,f))
7089 return qe_invalid;
7090 104960 strncpy(tempitem.display_name,str.c_str(),255);
7091
1/3
✓ Branch 0 taken 104960 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
104960 }
7092 156672 }
7093 else
7094 {
7095 4130 tempitem.count=-1;
7096 4130 tempitem.family=itype_misc;
7097 4130 tempitem.flags=item_none;
7098 4130 tempitem.wpn=tempitem.wpn2=tempitem.wpn3=tempitem.wpn3=tempitem.pickup_hearts=tempitem.misc1=tempitem.misc2=tempitem.usesound=0;
7099 4130 tempitem.playsound=WAV_SCALE;
7100 4130 reset_itembuf(&tempitem,i);
7101 }
7102
7103
2/2
✓ Branch 0 taken 57122 times.
✓ Branch 1 taken 103680 times.
160802 if(s_version >= 58)
7104 {
7105
2/2
✓ Branch 0 taken 518400 times.
✓ Branch 1 taken 103680 times.
622080 for(int q = 0; q < BURNSPR_MAX; ++q)
7106 {
7107
1/2
✓ Branch 0 taken 518400 times.
✗ Branch 1 not taken.
518400 if(!p_getc(&tempitem.burnsprs[q],f))
7108 return qe_invalid;
7109
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 518400 times.
518400 if(s_version >= 59)
7110
1/2
✓ Branch 0 taken 518400 times.
✗ Branch 1 not taken.
518400 if(!p_getc(&tempitem.light_rads[q],f))
7111 return qe_invalid;
7112 518400 }
7113 103680 }
7114
7115
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 160802 times.
160802 if (!should_skip)
7116 {
7117
1/2
✓ Branch 0 taken 160802 times.
✗ Branch 1 not taken.
160802 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
7118 {
7119 tempitem.script = 0;
7120 tempitem.weaponscript = 0;
7121 for(int q = 0; q < 8; ++q)
7122 {
7123 tempitem.initiald[q] = 0;
7124 tempitem.weap_initiald[q] = 0;
7125 }
7126 }
7127 160802 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
7128 160802 }
7129 160802 }
7130
7131
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 694 times.
695 if (should_skip)
7132 1 return 0;
7133
7134 //////////////////////////////////////////////////////
7135 // Now do any updates because of new item additions
7136 // (These can't be done above because items_to_read
7137 // might be too low.)
7138 //////////////////////////////////////////////////////
7139
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<MAXITEMS; i++)
7140 {
7141 177664 memcpy(&tempitem, &itemsbuf[i], sizeof(itemdata));
7142
7143 //Account for older quests that didn't have an actual item for the used letter
7144
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 156672 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
177664 if(s_version < 2 && i==iLetterUsed)
7145 {
7146 82 reset_itembuf(&tempitem, iLetterUsed);
7147 82 strcpy(item_string[i],old_item_string[i]);
7148 82 tempitem.tile = itemsbuf[iLetter].tile;
7149 82 tempitem.csets = itemsbuf[iLetter].csets;
7150 82 tempitem.misc_flags = itemsbuf[iLetter].misc_flags;
7151 82 tempitem.frames = itemsbuf[iLetter].frames;
7152 82 tempitem.speed = itemsbuf[iLetter].speed;
7153 82 tempitem.ltm = itemsbuf[iLetter].ltm;
7154 82 }
7155
7156
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 3)
7157 {
7158
3/3
✓ Branch 0 taken 1804 times.
✓ Branch 1 taken 19106 times.
✓ Branch 2 taken 82 times.
20992 switch(i)
7159 {
7160 case iRocsFeather:
7161 case iHoverBoots:
7162 case iSpinScroll:
7163 case iL2SpinScroll:
7164 case iCrossScroll:
7165 case iQuakeScroll:
7166 case iL2QuakeScroll:
7167 case iWhispRing:
7168 case iL2WhispRing:
7169 case iChargeRing:
7170 case iL2ChargeRing:
7171 case iPerilScroll:
7172 case iWalletL3:
7173 case iQuiverL4:
7174 case iBombBagL4:
7175 case iBracelet:
7176 case iL2Bracelet:
7177 case iOldGlove:
7178 case iL2Ladder:
7179 case iWealthMedal:
7180 case iL2WealthMedal:
7181 case iL3WealthMedal:
7182 1804 reset_itembuf(&tempitem, i);
7183 1804 strcpy(item_string[i],old_item_string[i]);
7184 1804 break;
7185
7186 case iSShield:
7187 82 reset_itembuf(&tempitem, i);
7188 82 strcpy(item_string[i],old_item_string[i]);
7189 82 strcpy(item_string[iShield],old_item_string[iShield]);
7190 82 strcpy(item_string[iMShield],old_item_string[iMShield]);
7191 82 break;
7192 }
7193 20992 }
7194
7195
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 5)
7196 {
7197
2/2
✓ Branch 0 taken 574 times.
✓ Branch 1 taken 20418 times.
20992 switch(i)
7198 {
7199 case iHeartRing:
7200 case iL2HeartRing:
7201 case iL3HeartRing:
7202 case iMagicRing:
7203 case iL2MagicRing:
7204 case iL3MagicRing:
7205 case iL4MagicRing:
7206 574 reset_itembuf(&tempitem, i);
7207 574 strcpy(item_string[i],old_item_string[i]);
7208 574 break;
7209 }
7210 20992 }
7211
7212
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 6) // April 2007: Advanced item editing capabilities.
7213 {
7214
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(i!=iBPotion && i!=iRPotion)
7215
2/2
✓ Branch 0 taken 19304 times.
✓ Branch 1 taken 1524 times.
20828 if (get_bit(deprecated_rules,32)) tempitem.flags |= item_keep_old;
7216
7217
43/43
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 328 times.
✓ Branch 8 taken 17302 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
✓ Branch 11 taken 82 times.
✓ Branch 12 taken 82 times.
✓ Branch 13 taken 82 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
✓ Branch 16 taken 82 times.
✓ Branch 17 taken 82 times.
✓ Branch 18 taken 82 times.
✓ Branch 19 taken 82 times.
✓ Branch 20 taken 82 times.
✓ Branch 21 taken 82 times.
✓ Branch 22 taken 82 times.
✓ Branch 23 taken 82 times.
✓ Branch 24 taken 82 times.
✓ Branch 25 taken 82 times.
✓ Branch 26 taken 82 times.
✓ Branch 27 taken 82 times.
✓ Branch 28 taken 82 times.
✓ Branch 29 taken 82 times.
✓ Branch 30 taken 82 times.
✓ Branch 31 taken 82 times.
✓ Branch 32 taken 82 times.
✓ Branch 33 taken 82 times.
✓ Branch 34 taken 82 times.
✓ Branch 35 taken 82 times.
✓ Branch 36 taken 82 times.
✓ Branch 37 taken 82 times.
✓ Branch 38 taken 82 times.
✓ Branch 39 taken 82 times.
✓ Branch 40 taken 82 times.
✓ Branch 41 taken 82 times.
✓ Branch 42 taken 82 times.
20992 switch(i)
7218 {
7219 case iTriforce:
7220 82 tempitem.fam_type=1;
7221 82 break;
7222
7223 case iBigTri:
7224 82 tempitem.fam_type=0;
7225 82 break;
7226
7227 case iBombs:
7228 82 tempitem.fam_type=i_bomb;
7229 82 tempitem.power=4;
7230 82 tempitem.wpn=wBOMB;
7231 82 tempitem.wpn2=wBOOM;
7232 82 tempitem.misc1 = 50;
7233
7234
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 200;
7235
7236 82 break;
7237
7238 case iSBomb:
7239 82 tempitem.fam_type=i_sbomb;
7240 82 tempitem.power=16;
7241 82 tempitem.wpn=wSBOMB;
7242 82 tempitem.wpn2=wSBOOM;
7243 82 tempitem.misc1 = 50;
7244
7245
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules,qr_SLOWBOMBFUSES_DEP)) tempitem.misc1 = 400;
7246
7247 82 break;
7248
7249 case iBook:
7250
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if(get_bit(deprecated_rules, qr_FIREMAGICSPRITE_DEP))
7251 tempitem.wpn = wFIREMAGIC;
7252
7253 82 break;
7254
7255 case iSArrow:
7256 82 tempitem.wpn2 = get_bit(deprecated_rules,27) ? wSSPARKLE : 0; //qr_SASPARKLES
7257 82 tempitem.power=4;
7258 82 tempitem.flags|=item_gamedata;
7259 82 tempitem.wpn=wSARROW;
7260 82 break;
7261
7262 case iGArrow:
7263 82 tempitem.wpn2 = get_bit(deprecated_rules,28) ? wGSPARKLE : 0; //qr_GASPARKLES
7264 82 tempitem.power=8;
7265 82 tempitem.flags|=(item_gamedata|item_flag1);
7266 82 tempitem.wpn=wGARROW;
7267 82 break;
7268
7269 case iBrang:
7270 82 tempitem.power=0;
7271 82 tempitem.wpn=wBRANG;
7272 82 tempitem.misc1=36;
7273 82 break;
7274
7275 case iMBrang:
7276 82 tempitem.wpn2 = get_bit(deprecated_rules,29) ? wMSPARKLE : 0; //qr_MBSPARKLES
7277 82 tempitem.power=0;
7278 82 tempitem.wpn=wMBRANG;
7279 82 break;
7280
7281 case iFBrang:
7282 82 tempitem.wpn3 = get_bit(deprecated_rules,30) ? wFSPARKLE : 0; //qr_FBSPARKLES
7283 82 tempitem.power=2;
7284 82 tempitem.wpn=wFBRANG;
7285 82 break;
7286
7287 case iBoots:
7288 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICBOOTS_DEP) ? 1 : 0;
7289 82 tempitem.power=7;
7290 82 break;
7291
7292 case iWand:
7293 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICWAND_DEP) ? 8 : 0;
7294 82 tempitem.power=2;
7295 82 tempitem.wpn=wWAND;
7296 82 tempitem.wpn3=wMAGIC;
7297 82 break;
7298
7299 case iBCandle:
7300 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7301 82 tempitem.power=1;
7302 82 tempitem.flags|=(item_gamedata|item_flag1);
7303 82 tempitem.wpn3=wFIRE;
7304 82 break;
7305
7306 case iRCandle:
7307 82 tempitem.cost_amount[0] = get_bit(deprecated_rules,qr_MAGICCANDLE_DEP) ? 4 : 0;
7308 82 tempitem.power=1;
7309 82 tempitem.wpn3=wFIRE;
7310 82 break;
7311
7312 case iSword:
7313 82 tempitem.power=1;
7314 82 tempitem.flags|= item_flag4 |item_flag2;
7315 82 tempitem.wpn=tempitem.wpn3=wSWORD;
7316 82 tempitem.wpn2=wSWORDSLASH;
7317 82 break;
7318
7319 case iWSword:
7320 82 tempitem.power=2;
7321 82 tempitem.flags|= item_flag4 |item_flag2;
7322 82 tempitem.wpn=tempitem.wpn3=wWSWORD;
7323 82 tempitem.wpn2=wWSWORDSLASH;
7324 82 break;
7325
7326 case iMSword:
7327 82 tempitem.power=4;
7328 82 tempitem.flags|= item_flag4 |item_flag2;
7329 82 tempitem.wpn=tempitem.wpn3=wMSWORD;
7330 82 tempitem.wpn2=wMSWORDSLASH;
7331 82 break;
7332
7333 case iXSword:
7334 82 tempitem.power=8;
7335 82 tempitem.flags|= item_flag4 |item_flag2;
7336 82 tempitem.wpn=tempitem.wpn3=wXSWORD;
7337 82 tempitem.wpn2=wXSWORDSLASH;
7338 82 break;
7339
7340 case iDivineProtection:
7341 82 tempitem.flags |= get_bit(deprecated_rules,qr_FLICKERINGDIVINEPROTECTIONROCKET_DEP) ? item_flag1 : item_none;
7342 82 tempitem.flags |= get_bit(deprecated_rules,qr_TRANSLUCENTDIVINEPROTECTIONROCKET_DEP) ? item_flag2 : item_none;
7343 82 tempitem.wpn=wDIVINEPROTECTION1A;
7344 82 tempitem.wpn2=wDIVINEPROTECTION1B;
7345 82 tempitem.wpn3=wDIVINEPROTECTIONS1A;
7346 82 tempitem.wpn4=wDIVINEPROTECTIONS1B;
7347 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7348 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7349 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7350 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7351 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7352 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7353 82 tempitem.misc1=512;
7354 82 tempitem.cost_amount[0]=64;
7355 82 break;
7356
7357 case iLens:
7358 82 tempitem.misc1=60;
7359 82 tempitem.flags |= get_qr(qr_ENABLEMAGIC) ? item_none : item_rupee_magic;
7360 82 tempitem.cost_amount[0] = get_qr(qr_ENABLEMAGIC) ? 2 : 1;
7361 82 break;
7362
7363 case iArrow:
7364 82 tempitem.power=2;
7365 82 tempitem.wpn=wARROW;
7366 82 break;
7367
7368 case iHoverBoots:
7369 82 tempitem.misc1=45;
7370 82 tempitem.wpn=iwHover;
7371 82 break;
7372
7373 case iDivineFire:
7374 82 tempitem.power=8;
7375 82 tempitem.wpn=wDIVINEFIRE1A;
7376 82 tempitem.wpn2=wDIVINEFIRE1B;
7377 82 tempitem.wpn3=wDIVINEFIRES1A;
7378 82 tempitem.wpn4=wDIVINEFIRES1B;
7379 82 tempitem.misc1 = 32;
7380 82 tempitem.misc2 = 200;
7381 82 tempitem.cost_amount[0]=32;
7382 82 break;
7383
7384 case iDivineEscape:
7385 82 tempitem.cost_amount[0]=32;
7386 82 break;
7387
7388 case iHookshot:
7389 82 tempitem.power=0;
7390 82 tempitem.flags&=~item_flag1;
7391 82 tempitem.wpn=wHSHEAD;
7392 82 tempitem.wpn2=wHSCHAIN_H;
7393 82 tempitem.wpn4=wHSHANDLE;
7394 82 tempitem.wpn3=wHSCHAIN_V;
7395 82 tempitem.misc1=50;
7396 82 tempitem.misc2=100;
7397 82 break;
7398
7399 case iLongshot:
7400 82 tempitem.power=0;
7401 82 tempitem.flags&=~item_flag1;
7402 82 tempitem.wpn=wLSHEAD;
7403 82 tempitem.wpn2=wLSCHAIN_H;
7404 82 tempitem.wpn4=wLSHANDLE;
7405 82 tempitem.wpn3=wLSCHAIN_V;
7406 82 tempitem.misc1=99;
7407 82 tempitem.misc2=100;
7408 82 break;
7409
7410 case iHammer:
7411 82 tempitem.power=4;
7412 82 tempitem.wpn=wHAMMER;
7413 82 tempitem.wpn2=iwHammerSmack;
7414 82 break;
7415
7416 case iCByrna:
7417 82 tempitem.power=1;
7418 82 tempitem.wpn=wCBYRNA;
7419 82 tempitem.wpn2=wCBYRNASLASH;
7420 82 tempitem.wpn3=wCBYRNAORB;
7421 82 tempitem.misc1=4;
7422 82 tempitem.misc2=16;
7423 82 tempitem.misc3=1;
7424 82 tempitem.cost_amount[0]=1;
7425 82 break;
7426
7427 case iWhistle:
7428 82 tempitem.wpn=wWIND;
7429 82 tempitem.misc1=3;
7430 82 tempitem.flags|=item_flag1;
7431 82 break;
7432
7433 case iBRing:
7434 82 tempitem.power=2;
7435 82 tempitem.misc1=spBLUE;
7436 82 break;
7437
7438 case iRRing:
7439 82 tempitem.power=4;
7440 82 tempitem.misc1=spRED;
7441 82 break;
7442
7443 case iGRing:
7444 82 tempitem.power=8;
7445 82 tempitem.misc1=spGOLD;
7446 82 break;
7447
7448 case iSpinScroll:
7449 82 tempitem.power = 2;
7450 82 tempitem.misc1 = 1;
7451 82 break;
7452
7453 case iL2SpinScroll:
7454 82 tempitem.family=itype_spinscroll2;
7455 82 tempitem.fam_type=1;
7456 82 tempitem.cost_amount[0]=8;
7457 82 tempitem.power=2;
7458 82 tempitem.misc1 = 20;
7459 82 break;
7460
7461 case iQuakeScroll:
7462 82 tempitem.misc1=0x10;
7463 82 tempitem.misc2=64;
7464 82 break;
7465
7466 case iL2QuakeScroll:
7467 82 tempitem.family=itype_quakescroll2;
7468 82 tempitem.fam_type=1;
7469 82 tempitem.power = 2;
7470 82 tempitem.misc1=0x20;
7471 82 tempitem.misc2=192;
7472 82 tempitem.cost_amount[0]=8;
7473 82 break;
7474
7475 case iChargeRing:
7476 82 tempitem.misc1=64;
7477 82 tempitem.misc2=128;
7478 82 break;
7479
7480 case iL2ChargeRing:
7481 82 tempitem.misc1=32;
7482 82 tempitem.misc2=64;
7483 82 break;
7484
7485 case iOldGlove:
7486 82 tempitem.flags |= item_flag1;
7487
7488 //fallthrough
7489 case iBombBagL4:
7490 case iWalletL3:
7491 case iQuiverL4:
7492 case iBracelet:
7493 410 tempitem.power = 1;
7494 410 break;
7495
7496 case iL2Bracelet:
7497 82 tempitem.power = 2;
7498 82 break;
7499
7500 case iMKey:
7501 82 tempitem.power=0xFF;
7502 82 tempitem.flags |= item_flag1;
7503 82 break;
7504 }
7505 20992 }
7506
7507
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 7)
7508 {
7509
2/2
✓ Branch 0 taken 328 times.
✓ Branch 1 taken 20664 times.
20992 switch(i)
7510 {
7511 case iStoneAgony:
7512 case iStompBoots:
7513 case iPerilRing:
7514 case iWhimsicalRing:
7515 {
7516 328 reset_itembuf(&tempitem, i);
7517 328 strcpy(item_string[i],old_item_string[i]);
7518 328 break;
7519 }
7520 }
7521 20992 }
7522
7523
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 8) // May 2007: Some corrections.
7524 {
7525
7/7
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 246 times.
✓ Branch 2 taken 20336 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
20992 switch(i)
7526 {
7527 case iMShield:
7528 82 tempitem.misc1|=sh_flame;
7529 82 tempitem.misc2|=sh_fireball|sh_magic;
7530
7531
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(get_qr(qr_SWORDMIRROR))
7532 {
7533 tempitem.misc2 |= sh_sword;
7534 }
7535
7536 // fallthrough
7537 case iShield:
7538 164 tempitem.misc1|=sh_fireball|sh_sword|sh_magic;
7539
7540 // fallthrough
7541 case iSShield:
7542 246 tempitem.misc1|=sh_rock|sh_arrow|sh_brang|sh_script;
7543
7544
1/2
✓ Branch 0 taken 246 times.
✗ Branch 1 not taken.
246 if(get_bit(deprecated_rules,102)) //qr_REFLECTROCKS
7545 {
7546 tempitem.misc2 |= sh_rock;
7547 }
7548
7549 246 break;
7550
7551 case iWhispRing:
7552 82 tempitem.power=1;
7553 82 tempitem.flags|=item_gamedata|item_flag1;
7554 82 tempitem.misc1 = 3;
7555 82 break;
7556
7557 case iL2WhispRing:
7558 82 tempitem.power=0;
7559 82 tempitem.flags|=item_gamedata|item_flag1;
7560 82 tempitem.misc1 = 3;
7561 82 break;
7562
7563 case iL2Ladder:
7564 case iBow:
7565 case iCByrna:
7566 246 tempitem.power = 1;
7567 246 break;
7568 }
7569 20992 }
7570
7571
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 156672 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
177664 if(s_version < 9 && i==iClock)
7572 {
7573 82 tempitem.misc1 = get_bit(deprecated_rules, qr_TEMPCLOCKS_DEP) ? 256 : 0;
7574 82 }
7575
7576 //add the misc flag for bomb
7577
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 156672 times.
✓ Branch 2 taken 20910 times.
✓ Branch 3 taken 82 times.
177664 if(s_version < 10 && tempitem.family == itype_bomb)
7578 {
7579 82 tempitem.flags = (tempitem.flags & ~item_flag1) | (get_qr(qr_LONGBOMBBOOM_DEP) ? item_flag1 : item_none);
7580 82 }
7581
7582
4/4
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 156672 times.
✓ Branch 2 taken 20828 times.
✓ Branch 3 taken 164 times.
177664 if(s_version < 11 && tempitem.family == itype_triforcepiece)
7583 {
7584 164 tempitem.flags = (tempitem.fam_type ? item_gamedata : item_none);
7585 164 tempitem.playsound = (tempitem.fam_type ? WAV_SCALE : WAV_CLEARED);
7586 164 }
7587
7588
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 12) // June 2007: More Misc. attributes.
7589 {
7590
5/5
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20582 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
20992 switch(i)
7591 {
7592 case iFBrang:
7593 82 tempitem.misc4 |= sh_fireball|sh_sword|sh_magic;
7594
7595 //fallthrough
7596 case iMBrang:
7597 164 tempitem.misc3 |= sh_sword|sh_magic;
7598
7599 //fallthrough
7600 case iHookshot:
7601 case iLongshot:
7602 //fallthrough
7603 328 tempitem.misc3 |= sh_fireball;
7604
7605 case iBrang:
7606 410 tempitem.misc3 |= sh_brang|sh_rock|sh_arrow;
7607 410 break;
7608 }
7609
7610
16/16
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 246 times.
✓ Branch 4 taken 246 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 328 times.
✓ Branch 9 taken 164 times.
✓ Branch 10 taken 9629 times.
✓ Branch 11 taken 164 times.
✓ Branch 12 taken 246 times.
✓ Branch 13 taken 9313 times.
✓ Branch 14 taken 82 times.
✓ Branch 15 taken 82 times.
20992 switch(tempitem.family)
7611 {
7612 case itype_hoverboots:
7613 82 tempitem.usesound = WAV_ZN1HOVER;
7614 82 break;
7615
7616 case itype_wand:
7617 82 tempitem.usesound = WAV_WAND;
7618 82 break;
7619
7620 case itype_book:
7621 82 tempitem.usesound = WAV_FIRE;
7622 82 break;
7623
7624 case itype_arrow:
7625 246 tempitem.usesound = WAV_ARROW;
7626 246 break;
7627
7628 case itype_hookshot:
7629 164 tempitem.usesound = WAV_HOOKSHOT;
7630 164 break;
7631
7632 case itype_brang:
7633 246 tempitem.usesound = WAV_BRANG;
7634 246 break;
7635
7636 case itype_shield:
7637 246 tempitem.usesound = WAV_CHINK;
7638 246 break;
7639
7640 case itype_sword:
7641 9313 tempitem.usesound = WAV_SWORD;
7642 9313 break;
7643
7644 case itype_whistle:
7645 82 tempitem.usesound = WAV_WHISTLE;
7646 82 break;
7647
7648 case itype_hammer:
7649 82 tempitem.usesound = WAV_HAMMER;
7650 82 break;
7651
7652 case itype_divinefire:
7653 82 tempitem.usesound = WAV_ZN1DIVINEFIRE;
7654 82 break;
7655
7656 case itype_divineescape:
7657 82 tempitem.usesound = WAV_ZN1DIVINEESCAPE;
7658 82 break;
7659
7660 case itype_divineprotection:
7661 82 tempitem.usesound = WAV_ZN1DIVINEPROTECTION1;
7662 82 break;
7663
7664 case itype_bomb:
7665 case itype_sbomb:
7666 case itype_quakescroll:
7667 case itype_quakescroll2:
7668 328 tempitem.usesound = WAV_BOMB;
7669 328 break;
7670
7671 case itype_spinscroll:
7672 case itype_spinscroll2:
7673 164 tempitem.usesound = WAV_ZN1SPINATTACK;
7674 164 break;
7675 }
7676 20992 }
7677
7678
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 13) // July 2007
7679 {
7680
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7681 {
7682 82 tempitem.misc1 = (tempitem.power==2 ? 4 : 3);
7683 82 tempitem.power = 1;
7684 82 tempitem.flags|=item_flag1;
7685 82 }
7686
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_wand)
7687 82 tempitem.flags|=item_flag1;
7688
2/2
✓ Branch 0 taken 20746 times.
✓ Branch 1 taken 82 times.
20828 else if(tempitem.family == itype_book)
7689 {
7690 82 tempitem.flags|=item_flag1;
7691 82 tempitem.power = 2;
7692 82 }
7693 20992 }
7694
7695
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 14) // August 2007
7696 {
7697
2/2
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
20992 if(tempitem.family == itype_fairy)
7698 {
7699 164 tempitem.usesound = WAV_SCALE;
7700
7701
1/2
✓ Branch 0 taken 164 times.
✗ Branch 1 not taken.
164 if(tempitem.fam_type)
7702 164 tempitem.misc3=50;
7703 164 }
7704
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_potion)
7705 {
7706 164 tempitem.flags |= item_gain_old;
7707 164 }
7708 20992 }
7709
7710
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 17) // November 2007
7711 {
7712
3/4
✓ Branch 0 taken 164 times.
✓ Branch 1 taken 20828 times.
✓ Branch 2 taken 164 times.
✗ Branch 3 not taken.
20992 if(tempitem.family == itype_candle && !tempitem.wpn3)
7713 {
7714 tempitem.wpn3 = wFIRE;
7715 }
7716
4/4
✓ Branch 0 taken 246 times.
✓ Branch 1 taken 20746 times.
✓ Branch 2 taken 164 times.
✓ Branch 3 taken 82 times.
20992 else if(tempitem.family == itype_arrow && tempitem.power>4)
7717 {
7718 82 tempitem.flags|=item_flag1;
7719 82 }
7720 20992 }
7721
7722
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 18) // New Year's Eve 2007
7723 {
7724
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_whistle)
7725 82 tempitem.misc2 = 8; // Use the Whistle warp ring
7726
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20828 times.
20910 else if(tempitem.family == itype_bait)
7727 82 tempitem.misc1 = 768; // Frames until it goes
7728
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 164 times.
20828 else if(tempitem.family == itype_triforcepiece)
7729 {
7730
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
164 if(tempitem.flags & item_gamedata)
7731 {
7732 82 tempitem.misc2 = 1; // Cutscene 1
7733 82 tempitem.flags |= item_flag1; // Side Warp Out
7734 82 }
7735 164 }
7736 20992 }
7737
7738
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 19) // January 2008
7739 {
7740
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7741 {
7742
2/2
✓ Branch 0 taken 2 times.
✓ Branch 1 taken 80 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+1)) tempitem.flags |= item_flag3;
7743
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 72 times.
82 if (get_bit(deprecated_rules,qr_NOBOMBPALFLASH+2)) tempitem.flags |= item_flag4;
7744 82 }
7745 20992 }
7746
7747
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 20) // October 2008
7748 {
7749
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divineprotection)
7750 {
7751 82 tempitem.wpn6=wDIVINEPROTECTION2A;
7752 82 tempitem.wpn7=wDIVINEPROTECTION2B;
7753 82 tempitem.wpn8=wDIVINEPROTECTIONS2A;
7754 82 tempitem.wpn9=wDIVINEPROTECTIONS2B;
7755 82 tempitem.wpn5 = iwDivineProtectionShieldFront;
7756 82 tempitem.wpn10 = iwDivineProtectionShieldBack;
7757 82 }
7758 20992 }
7759
7760
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 21) // November 2008
7761 {
7762
1/2
✓ Branch 0 taken 20992 times.
✗ Branch 1 not taken.
20992 if(tempitem.flags & 0x0100) // item_slash
7763 {
7764 tempitem.flags &= ~item_unused;
7765
7766 if(tempitem.family == itype_sword ||
7767 tempitem.family == itype_wand ||
7768 tempitem.family == itype_candle ||
7769 tempitem.family == itype_cbyrna)
7770 {
7771 tempitem.flags |= item_flag4;
7772 }
7773 }
7774 20992 }
7775
7776
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 22) // September 2009
7777 {
7778
4/4
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 20828 times.
20992 if(tempitem.family == itype_sbomb || tempitem.family == itype_bomb)
7779 {
7780 164 tempitem.misc3 = tempitem.power/2;
7781 164 }
7782 20992 }
7783
7784
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 23) // March 2011
7785 {
7786
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 20910 times.
20992 if(tempitem.family == itype_divinefire)
7787 82 tempitem.wpn5 = wFIRE;
7788
2/2
✓ Branch 0 taken 20828 times.
✓ Branch 1 taken 82 times.
20910 else if(tempitem.family == itype_book)
7789 82 tempitem.wpn2 = wFIRE;
7790 20992 }
7791
7792 // Version 25: Bomb bags were acting as though "super bombs also" was checked
7793 // whether it was or not, and a lot of existing quests depended on the
7794 // incorrect behavior.
7795
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 20992 times.
177664 if(s_version < 25) // January 2012
7796 {
7797
2/2
✓ Branch 0 taken 20664 times.
✓ Branch 1 taken 328 times.
20992 if(tempitem.family == itype_bombbag)
7798 328 tempitem.flags |= item_flag1;
7799
7800
2/2
✓ Branch 0 taken 20910 times.
✓ Branch 1 taken 82 times.
20992 if(tempitem.family == itype_divinefire)
7801 82 tempitem.flags |= item_flag3; // Sideview gravity flag
7802 20992 }
7803
7804
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( version < 0x254) //Nuke greyed-out flags/values from <=2.53, in case they are used in 2.54/2.55
7805 {
7806
60/60
✓ Branch 0 taken 17515 times.
✓ Branch 1 taken 813 times.
✓ Branch 2 taken 801 times.
✓ Branch 3 taken 580 times.
✓ Branch 4 taken 317 times.
✓ Branch 5 taken 271 times.
✓ Branch 6 taken 538 times.
✓ Branch 7 taken 593 times.
✓ Branch 8 taken 287 times.
✓ Branch 9 taken 861 times.
✓ Branch 10 taken 861 times.
✓ Branch 11 taken 534 times.
✓ Branch 12 taken 821 times.
✓ Branch 13 taken 538 times.
✓ Branch 14 taken 269 times.
✓ Branch 15 taken 538 times.
✓ Branch 16 taken 285 times.
✓ Branch 17 taken 269 times.
✓ Branch 18 taken 813 times.
✓ Branch 19 taken 271 times.
✓ Branch 20 taken 273 times.
✓ Branch 21 taken 540 times.
✓ Branch 22 taken 245 times.
✓ Branch 23 taken 271 times.
✓ Branch 24 taken 269 times.
✓ Branch 25 taken 269 times.
✓ Branch 26 taken 269 times.
✓ Branch 27 taken 285 times.
✓ Branch 28 taken 271 times.
✓ Branch 29 taken 271 times.
✓ Branch 30 taken 269 times.
✓ Branch 31 taken 273 times.
✓ Branch 32 taken 538 times.
✓ Branch 33 taken 1076 times.
✓ Branch 34 taken 759 times.
✓ Branch 35 taken 269 times.
✓ Branch 36 taken 523 times.
✓ Branch 37 taken 1076 times.
✓ Branch 38 taken 269 times.
✓ Branch 39 taken 269 times.
✓ Branch 40 taken 269 times.
✓ Branch 41 taken 269 times.
✓ Branch 42 taken 269 times.
✓ Branch 43 taken 540 times.
✓ Branch 44 taken 538 times.
✓ Branch 45 taken 269 times.
✓ Branch 46 taken 809 times.
✓ Branch 47 taken 811 times.
✓ Branch 48 taken 1084 times.
✓ Branch 49 taken 269 times.
✓ Branch 50 taken 269 times.
✓ Branch 51 taken 269 times.
✓ Branch 52 taken 269 times.
✓ Branch 53 taken 269 times.
✓ Branch 54 taken 295 times.
✓ Branch 55 taken 9413 times.
✓ Branch 56 taken 2766 times.
✓ Branch 57 taken 811 times.
✓ Branch 58 taken 3150 times.
✓ Branch 59 taken 10679 times.
69376 switch(tempitem.family)
7807 {
7808 case itype_sword:
7809 {
7810 17515 tempitem.flags &= ~(item_flag5);
7811 17515 tempitem.misc3 = 0;
7812 17515 tempitem.misc4 = 0;
7813 17515 tempitem.misc5 = 0;
7814 17515 tempitem.misc6 = 0;
7815 17515 tempitem.misc7 = 0;
7816 17515 tempitem.misc8 = 0;
7817 17515 tempitem.misc9 = 0;
7818 17515 tempitem.misc10 = 0;
7819 17515 tempitem.wpn4 = 0;
7820 17515 tempitem.wpn5 = 0;
7821 17515 tempitem.wpn6 = 0;
7822 17515 tempitem.wpn7 = 0;
7823 17515 tempitem.wpn8 = 0;
7824 17515 tempitem.wpn9 = 0;
7825 17515 tempitem.wpn10 = 0;
7826 17515 break;
7827 }
7828 case itype_brang:
7829 {
7830 813 tempitem.flags &= ~(item_flag4 | item_flag5);
7831 813 tempitem.misc2 = 0;
7832 813 tempitem.misc5 = 0;
7833 813 tempitem.misc6 = 0;
7834 813 tempitem.misc7 = 0;
7835 813 tempitem.misc8 = 0;
7836 813 tempitem.misc9 = 0;
7837 813 tempitem.misc10 = 0;
7838 813 tempitem.wpn4 = 0;
7839 813 tempitem.wpn5 = 0;
7840 813 tempitem.wpn6 = 0;
7841 813 tempitem.wpn7 = 0;
7842 813 tempitem.wpn8 = 0;
7843 813 tempitem.wpn9 = 0;
7844 813 tempitem.wpn10 = 0;
7845 813 break;
7846 }
7847 case itype_arrow:
7848 {
7849 801 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7850 801 tempitem.misc2 = 0;
7851 801 tempitem.misc3 = 0;
7852 801 tempitem.misc4 = 0;
7853 801 tempitem.misc5 = 0;
7854 801 tempitem.misc6 = 0;
7855 801 tempitem.misc7 = 0;
7856 801 tempitem.misc8 = 0;
7857 801 tempitem.misc9 = 0;
7858 801 tempitem.misc10 = 0;
7859 801 tempitem.wpn4 = 0;
7860 801 tempitem.wpn5 = 0;
7861 801 tempitem.wpn6 = 0;
7862 801 tempitem.wpn7 = 0;
7863 801 tempitem.wpn8 = 0;
7864 801 tempitem.wpn9 = 0;
7865 801 tempitem.wpn10 = 0;
7866 801 break;
7867 }
7868 case itype_candle:
7869 {
7870 580 tempitem.flags &= ~ (item_flag3 | item_flag5);
7871 580 tempitem.misc1 = 0;
7872 580 tempitem.misc2 = 0;
7873 580 tempitem.misc3 = 0;
7874 580 tempitem.misc4 = 0;
7875 580 tempitem.misc5 = 0;
7876 580 tempitem.misc6 = 0;
7877 580 tempitem.misc7 = 0;
7878 580 tempitem.misc8 = 0;
7879 580 tempitem.misc9 = 0;
7880 580 tempitem.misc10 = 0;
7881 580 tempitem.wpn4 = 0;
7882 580 tempitem.wpn5 = 0;
7883 580 tempitem.wpn6 = 0;
7884 580 tempitem.wpn7 = 0;
7885 580 tempitem.wpn8 = 0;
7886 580 tempitem.wpn9 = 0;
7887 580 tempitem.wpn10 = 0;
7888 580 break;
7889 }
7890 case itype_whistle:
7891 {
7892 317 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
7893 317 tempitem.misc3 = 0;
7894 317 tempitem.misc4 = 0;
7895 317 tempitem.misc5 = 0;
7896 317 tempitem.misc6 = 0;
7897 317 tempitem.misc7 = 0;
7898 317 tempitem.misc8 = 0;
7899 317 tempitem.misc9 = 0;
7900 317 tempitem.misc10 = 0;
7901 317 tempitem.wpn2 = 0;
7902 317 tempitem.wpn3 = 0;
7903 317 tempitem.wpn4 = 0;
7904 317 tempitem.wpn5 = 0;
7905 317 tempitem.wpn6 = 0;
7906 317 tempitem.wpn7 = 0;
7907 317 tempitem.wpn8 = 0;
7908 317 tempitem.wpn9 = 0;
7909 317 tempitem.wpn10 = 0;
7910 317 break;
7911 }
7912 case itype_bait:
7913 {
7914 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7915 271 tempitem.misc2 = 0;
7916 271 tempitem.misc3 = 0;
7917 271 tempitem.misc4 = 0;
7918 271 tempitem.misc5 = 0;
7919 271 tempitem.misc6 = 0;
7920 271 tempitem.misc7 = 0;
7921 271 tempitem.misc8 = 0;
7922 271 tempitem.misc9 = 0;
7923 271 tempitem.misc10 = 0;
7924 271 tempitem.wpn2 = 0;
7925 271 tempitem.wpn3 = 0;
7926 271 tempitem.wpn4 = 0;
7927 271 tempitem.wpn5 = 0;
7928 271 tempitem.wpn6 = 0;
7929 271 tempitem.wpn7 = 0;
7930 271 tempitem.wpn8 = 0;
7931 271 tempitem.wpn9 = 0;
7932 271 tempitem.wpn10 = 0;
7933 271 break;
7934 }
7935 case itype_letter:
7936 {
7937 538 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
7938 538 tempitem.misc1 = 0;
7939 538 tempitem.misc2 = 0;
7940 538 tempitem.misc3 = 0;
7941 538 tempitem.misc4 = 0;
7942 538 tempitem.misc5 = 0;
7943 538 tempitem.misc6 = 0;
7944 538 tempitem.misc7 = 0;
7945 538 tempitem.misc8 = 0;
7946 538 tempitem.misc9 = 0;
7947 538 tempitem.misc10 = 0;
7948 538 tempitem.wpn = 0;
7949 538 tempitem.wpn2 = 0;
7950 538 tempitem.wpn3 = 0;
7951 538 tempitem.wpn4 = 0;
7952 538 tempitem.wpn5 = 0;
7953 538 tempitem.wpn6 = 0;
7954 538 tempitem.wpn7 = 0;
7955 538 tempitem.wpn8 = 0;
7956 538 tempitem.wpn9 = 0;
7957 538 tempitem.wpn10 = 0;
7958 538 break;
7959 }
7960 case itype_potion:
7961 {
7962 593 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
7963 593 tempitem.misc3 = 0;
7964 593 tempitem.misc4 = 0;
7965 593 tempitem.misc5 = 0;
7966 593 tempitem.misc6 = 0;
7967 593 tempitem.misc7 = 0;
7968 593 tempitem.misc8 = 0;
7969 593 tempitem.misc9 = 0;
7970 593 tempitem.misc10 = 0;
7971 593 tempitem.wpn = 0;
7972 593 tempitem.wpn2 = 0;
7973 593 tempitem.wpn3 = 0;
7974 593 tempitem.wpn4 = 0;
7975 593 tempitem.wpn5 = 0;
7976 593 tempitem.wpn6 = 0;
7977 593 tempitem.wpn7 = 0;
7978 593 tempitem.wpn8 = 0;
7979 593 tempitem.wpn9 = 0;
7980 593 tempitem.wpn10 = 0;
7981 593 break;
7982 }
7983 case itype_wand:
7984 {
7985 287 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
7986 287 tempitem.misc1 = 0;
7987 287 tempitem.misc2 = 0;
7988 287 tempitem.misc3 = 0;
7989 287 tempitem.misc4 = 0;
7990 287 tempitem.misc5 = 0;
7991 287 tempitem.misc6 = 0;
7992 287 tempitem.misc7 = 0;
7993 287 tempitem.misc8 = 0;
7994 287 tempitem.misc9 = 0;
7995 287 tempitem.misc10 = 0;
7996 287 tempitem.wpn4 = 0;
7997 287 tempitem.wpn5 = 0;
7998 287 tempitem.wpn6 = 0;
7999 287 tempitem.wpn7 = 0;
8000 287 tempitem.wpn8 = 0;
8001 287 tempitem.wpn9 = 0;
8002 287 tempitem.wpn10 = 0;
8003 287 break;
8004 }
8005 case itype_ring:
8006 {
8007 861 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8008 861 tempitem.misc2 = 0;
8009 861 tempitem.misc3 = 0;
8010 861 tempitem.misc4 = 0;
8011 861 tempitem.misc5 = 0;
8012 861 tempitem.misc6 = 0;
8013 861 tempitem.misc7 = 0;
8014 861 tempitem.misc8 = 0;
8015 861 tempitem.misc9 = 0;
8016 861 tempitem.misc10 = 0;
8017 861 tempitem.wpn = 0;
8018 861 tempitem.wpn2 = 0;
8019 861 tempitem.wpn3 = 0;
8020 861 tempitem.wpn4 = 0;
8021 861 tempitem.wpn5 = 0;
8022 861 tempitem.wpn6 = 0;
8023 861 tempitem.wpn7 = 0;
8024 861 tempitem.wpn8 = 0;
8025 861 tempitem.wpn9 = 0;
8026 861 tempitem.wpn10 = 0;
8027 861 break;
8028 }
8029 case itype_wallet:
8030 {
8031 861 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8032 861 tempitem.misc3 = 0;
8033 861 tempitem.misc4 = 0;
8034 861 tempitem.misc5 = 0;
8035 861 tempitem.misc6 = 0;
8036 861 tempitem.misc7 = 0;
8037 861 tempitem.misc8 = 0;
8038 861 tempitem.misc9 = 0;
8039 861 tempitem.misc10 = 0;
8040 861 tempitem.wpn = 0;
8041 861 tempitem.wpn2 = 0;
8042 861 tempitem.wpn3 = 0;
8043 861 tempitem.wpn4 = 0;
8044 861 tempitem.wpn5 = 0;
8045 861 tempitem.wpn6 = 0;
8046 861 tempitem.wpn7 = 0;
8047 861 tempitem.wpn8 = 0;
8048 861 tempitem.wpn9 = 0;
8049 861 tempitem.wpn10 = 0;
8050 861 break;
8051 }
8052 case itype_amulet:
8053 {
8054 534 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8055 534 tempitem.misc1 = 0;
8056 534 tempitem.misc2 = 0;
8057 534 tempitem.misc3 = 0;
8058 534 tempitem.misc4 = 0;
8059 534 tempitem.misc5 = 0;
8060 534 tempitem.misc6 = 0;
8061 534 tempitem.misc7 = 0;
8062 534 tempitem.misc8 = 0;
8063 534 tempitem.misc9 = 0;
8064 534 tempitem.misc10 = 0;
8065 534 tempitem.wpn = 0;
8066 534 tempitem.wpn2 = 0;
8067 534 tempitem.wpn3 = 0;
8068 534 tempitem.wpn4 = 0;
8069 534 tempitem.wpn5 = 0;
8070 534 tempitem.wpn6 = 0;
8071 534 tempitem.wpn7 = 0;
8072 534 tempitem.wpn8 = 0;
8073 534 tempitem.wpn9 = 0;
8074 534 tempitem.wpn10 = 0;
8075 534 break;
8076 }
8077 case itype_shield:
8078 {
8079 821 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8080 821 tempitem.misc3 = 0;
8081 821 tempitem.misc4 = 0;
8082 821 tempitem.misc5 = 0;
8083 821 tempitem.misc6 = 0;
8084 821 tempitem.misc7 = 0;
8085 821 tempitem.misc8 = 0;
8086 821 tempitem.misc9 = 0;
8087 821 tempitem.misc10 = 0;
8088 821 tempitem.wpn = 0;
8089 821 tempitem.wpn2 = 0;
8090 821 tempitem.wpn3 = 0;
8091 821 tempitem.wpn4 = 0;
8092 821 tempitem.wpn5 = 0;
8093 821 tempitem.wpn6 = 0;
8094 821 tempitem.wpn7 = 0;
8095 821 tempitem.wpn8 = 0;
8096 821 tempitem.wpn9 = 0;
8097 821 tempitem.wpn10 = 0;
8098 821 break;
8099 }
8100 case itype_bow:
8101 {
8102 538 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8103 538 tempitem.misc1 = 0;
8104 538 tempitem.misc2 = 0;
8105 538 tempitem.misc3 = 0;
8106 538 tempitem.misc4 = 0;
8107 538 tempitem.misc5 = 0;
8108 538 tempitem.misc6 = 0;
8109 538 tempitem.misc7 = 0;
8110 538 tempitem.misc8 = 0;
8111 538 tempitem.misc9 = 0;
8112 538 tempitem.misc10 = 0;
8113 538 tempitem.wpn = 0;
8114 538 tempitem.wpn2 = 0;
8115 538 tempitem.wpn3 = 0;
8116 538 tempitem.wpn4 = 0;
8117 538 tempitem.wpn5 = 0;
8118 538 tempitem.wpn6 = 0;
8119 538 tempitem.wpn7 = 0;
8120 538 tempitem.wpn8 = 0;
8121 538 tempitem.wpn9 = 0;
8122 538 tempitem.wpn10 = 0;
8123 538 break;
8124 }
8125 case itype_raft:
8126 {
8127 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8128 269 tempitem.misc1 = 0;
8129 269 tempitem.misc2 = 0;
8130 269 tempitem.misc3 = 0;
8131 269 tempitem.misc4 = 0;
8132 269 tempitem.misc5 = 0;
8133 269 tempitem.misc6 = 0;
8134 269 tempitem.misc7 = 0;
8135 269 tempitem.misc8 = 0;
8136 269 tempitem.misc9 = 0;
8137 269 tempitem.misc10 = 0;
8138 269 tempitem.wpn = 0;
8139 269 tempitem.wpn2 = 0;
8140 269 tempitem.wpn3 = 0;
8141 269 tempitem.wpn4 = 0;
8142 269 tempitem.wpn5 = 0;
8143 269 tempitem.wpn6 = 0;
8144 269 tempitem.wpn7 = 0;
8145 269 tempitem.wpn8 = 0;
8146 269 tempitem.wpn9 = 0;
8147 269 tempitem.wpn10 = 0;
8148 269 break;
8149 }
8150 case itype_ladder:
8151 {
8152 538 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8153 538 tempitem.misc1 = 0;
8154 538 tempitem.misc2 = 0;
8155 538 tempitem.misc3 = 0;
8156 538 tempitem.misc4 = 0;
8157 538 tempitem.misc5 = 0;
8158 538 tempitem.misc6 = 0;
8159 538 tempitem.misc7 = 0;
8160 538 tempitem.misc8 = 0;
8161 538 tempitem.misc9 = 0;
8162 538 tempitem.misc10 = 0;
8163 538 tempitem.wpn = 0;
8164 538 tempitem.wpn2 = 0;
8165 538 tempitem.wpn3 = 0;
8166 538 tempitem.wpn4 = 0;
8167 538 tempitem.wpn5 = 0;
8168 538 tempitem.wpn6 = 0;
8169 538 tempitem.wpn7 = 0;
8170 538 tempitem.wpn8 = 0;
8171 538 tempitem.wpn9 = 0;
8172 538 tempitem.wpn10 = 0;
8173 538 break;
8174 }
8175 case itype_book:
8176 {
8177 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8178 285 tempitem.misc1 = 0;
8179 285 tempitem.misc2 = 0;
8180 285 tempitem.misc3 = 0;
8181 285 tempitem.misc4 = 0;
8182 285 tempitem.misc5 = 0;
8183 285 tempitem.misc6 = 0;
8184 285 tempitem.misc7 = 0;
8185 285 tempitem.misc8 = 0;
8186 285 tempitem.misc9 = 0;
8187 285 tempitem.misc10 = 0;
8188 285 tempitem.wpn3 = 0;
8189 285 tempitem.wpn4 = 0;
8190 285 tempitem.wpn5 = 0;
8191 285 tempitem.wpn6 = 0;
8192 285 tempitem.wpn7 = 0;
8193 285 tempitem.wpn8 = 0;
8194 285 tempitem.wpn9 = 0;
8195 285 tempitem.wpn10 = 0;
8196 285 break;
8197 }
8198 case itype_magickey:
8199 {
8200 269 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8201 269 tempitem.misc1 = 0;
8202 269 tempitem.misc2 = 0;
8203 269 tempitem.misc3 = 0;
8204 269 tempitem.misc4 = 0;
8205 269 tempitem.misc5 = 0;
8206 269 tempitem.misc6 = 0;
8207 269 tempitem.misc7 = 0;
8208 269 tempitem.misc8 = 0;
8209 269 tempitem.misc9 = 0;
8210 269 tempitem.misc10 = 0;
8211 269 tempitem.wpn = 0;
8212 269 tempitem.wpn2 = 0;
8213 269 tempitem.wpn3 = 0;
8214 269 tempitem.wpn4 = 0;
8215 269 tempitem.wpn5 = 0;
8216 269 tempitem.wpn6 = 0;
8217 269 tempitem.wpn7 = 0;
8218 269 tempitem.wpn8 = 0;
8219 269 tempitem.wpn9 = 0;
8220 269 tempitem.wpn10 = 0;
8221 269 break;
8222 }
8223 case itype_bracelet:
8224 {
8225 813 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8226 813 tempitem.misc1 = 0;
8227 813 tempitem.misc2 = 0;
8228 813 tempitem.misc3 = 0;
8229 813 tempitem.misc4 = 0;
8230 813 tempitem.misc5 = 0;
8231 813 tempitem.misc6 = 0;
8232 813 tempitem.misc7 = 0;
8233 813 tempitem.misc8 = 0;
8234 813 tempitem.misc9 = 0;
8235 813 tempitem.misc10 = 0;
8236 813 tempitem.wpn = 0;
8237 813 tempitem.wpn2 = 0;
8238 813 tempitem.wpn3 = 0;
8239 813 tempitem.wpn4 = 0;
8240 813 tempitem.wpn5 = 0;
8241 813 tempitem.wpn6 = 0;
8242 813 tempitem.wpn7 = 0;
8243 813 tempitem.wpn8 = 0;
8244 813 tempitem.wpn9 = 0;
8245 813 tempitem.wpn10 = 0;
8246 813 break;
8247 }
8248 case itype_flippers:
8249 {
8250 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8251 271 tempitem.misc1 = 0;
8252 271 tempitem.misc2 = 0;
8253 271 tempitem.misc3 = 0;
8254 271 tempitem.misc4 = 0;
8255 271 tempitem.misc5 = 0;
8256 271 tempitem.misc6 = 0;
8257 271 tempitem.misc7 = 0;
8258 271 tempitem.misc8 = 0;
8259 271 tempitem.misc9 = 0;
8260 271 tempitem.misc10 = 0;
8261 271 tempitem.wpn = 0;
8262 271 tempitem.wpn2 = 0;
8263 271 tempitem.wpn3 = 0;
8264 271 tempitem.wpn4 = 0;
8265 271 tempitem.wpn5 = 0;
8266 271 tempitem.wpn6 = 0;
8267 271 tempitem.wpn7 = 0;
8268 271 tempitem.wpn8 = 0;
8269 271 tempitem.wpn9 = 0;
8270 271 tempitem.wpn10 = 0;
8271 271 break;
8272 }
8273 case itype_boots:
8274 {
8275 273 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8276 273 tempitem.misc1 = 0;
8277 273 tempitem.misc2 = 0;
8278 273 tempitem.misc3 = 0;
8279 273 tempitem.misc4 = 0;
8280 273 tempitem.misc5 = 0;
8281 273 tempitem.misc6 = 0;
8282 273 tempitem.misc7 = 0;
8283 273 tempitem.misc8 = 0;
8284 273 tempitem.misc9 = 0;
8285 273 tempitem.misc10 = 0;
8286 273 tempitem.wpn = 0;
8287 273 tempitem.wpn2 = 0;
8288 273 tempitem.wpn3 = 0;
8289 273 tempitem.wpn4 = 0;
8290 273 tempitem.wpn5 = 0;
8291 273 tempitem.wpn6 = 0;
8292 273 tempitem.wpn7 = 0;
8293 273 tempitem.wpn8 = 0;
8294 273 tempitem.wpn9 = 0;
8295 273 tempitem.wpn10 = 0;
8296 273 break;
8297 }
8298 case itype_hookshot:
8299 {
8300 540 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8301 540 tempitem.misc5 = 0;
8302 540 tempitem.misc6 = 0;
8303 540 tempitem.misc7 = 0;
8304 540 tempitem.misc8 = 0;
8305 540 tempitem.misc9 = 0;
8306 540 tempitem.misc10 = 0;
8307 540 tempitem.wpn5 = 0;
8308 540 tempitem.wpn6 = 0;
8309 540 tempitem.wpn7 = 0;
8310 540 tempitem.wpn8 = 0;
8311 540 tempitem.wpn9 = 0;
8312 540 tempitem.wpn10 = 0;
8313 540 break;
8314 }
8315 case itype_lens:
8316 {
8317 245 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8318 245 tempitem.misc2 = 0;
8319 245 tempitem.misc3 = 0;
8320 245 tempitem.misc4 = 0;
8321 245 tempitem.misc5 = 0;
8322 245 tempitem.misc6 = 0;
8323 245 tempitem.misc7 = 0;
8324 245 tempitem.misc8 = 0;
8325 245 tempitem.misc9 = 0;
8326 245 tempitem.misc10 = 0;
8327 245 tempitem.wpn = 0;
8328 245 tempitem.wpn2 = 0;
8329 245 tempitem.wpn3 = 0;
8330 245 tempitem.wpn4 = 0;
8331 245 tempitem.wpn5 = 0;
8332 245 tempitem.wpn6 = 0;
8333 245 tempitem.wpn7 = 0;
8334 245 tempitem.wpn8 = 0;
8335 245 tempitem.wpn9 = 0;
8336 245 tempitem.wpn10 = 0;
8337 245 break;
8338 }
8339 case itype_hammer:
8340 {
8341 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8342 271 tempitem.misc1 = 0;
8343 271 tempitem.misc2 = 0;
8344 271 tempitem.misc3 = 0;
8345 271 tempitem.misc4 = 0;
8346 271 tempitem.misc5 = 0;
8347 271 tempitem.misc6 = 0;
8348 271 tempitem.misc7 = 0;
8349 271 tempitem.misc8 = 0;
8350 271 tempitem.misc9 = 0;
8351 271 tempitem.misc10 = 0;
8352 271 tempitem.wpn3 = 0;
8353 271 tempitem.wpn4 = 0;
8354 271 tempitem.wpn5 = 0;
8355 271 tempitem.wpn6 = 0;
8356 271 tempitem.wpn7 = 0;
8357 271 tempitem.wpn8 = 0;
8358 271 tempitem.wpn9 = 0;
8359 271 tempitem.wpn10 = 0;
8360 271 break;
8361 }
8362 case itype_divinefire:
8363 {
8364 269 tempitem.flags &= ~ (item_flag1 | item_flag4 | item_flag5);
8365 269 tempitem.misc3 = 0;
8366 269 tempitem.misc4 = 0;
8367 269 tempitem.misc5 = 0;
8368 269 tempitem.misc6 = 0;
8369 269 tempitem.misc7 = 0;
8370 269 tempitem.misc8 = 0;
8371 269 tempitem.misc9 = 0;
8372 269 tempitem.misc10 = 0;
8373 269 tempitem.wpn6 = 0;
8374 269 tempitem.wpn7 = 0;
8375 269 tempitem.wpn8 = 0;
8376 269 tempitem.wpn9 = 0;
8377 269 tempitem.wpn10 = 0;
8378 269 break;
8379 }
8380 case itype_divineescape:
8381 {
8382 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8383 269 tempitem.misc2 = 0;
8384 269 tempitem.misc3 = 0;
8385 269 tempitem.misc4 = 0;
8386 269 tempitem.misc5 = 0;
8387 269 tempitem.misc6 = 0;
8388 269 tempitem.misc7 = 0;
8389 269 tempitem.misc8 = 0;
8390 269 tempitem.misc9 = 0;
8391 269 tempitem.misc10 = 0;
8392 269 tempitem.wpn = 0;
8393 269 tempitem.wpn2 = 0;
8394 269 tempitem.wpn3 = 0;
8395 269 tempitem.wpn4 = 0;
8396 269 tempitem.wpn5 = 0;
8397 269 tempitem.wpn6 = 0;
8398 269 tempitem.wpn7 = 0;
8399 269 tempitem.wpn8 = 0;
8400 269 tempitem.wpn9 = 0;
8401 269 tempitem.wpn10 = 0;
8402 269 break;
8403 }
8404 case itype_divineprotection:
8405 {
8406 269 tempitem.flags &= ~ (item_flag5);
8407 269 tempitem.misc2 = 0;
8408 269 tempitem.misc3 = 0;
8409 269 tempitem.misc4 = 0;
8410 269 tempitem.misc5 = 0;
8411 269 tempitem.misc6 = 0;
8412 269 tempitem.misc7 = 0;
8413 269 tempitem.misc8 = 0;
8414 269 tempitem.misc9 = 0;
8415 269 tempitem.misc10 = 0;
8416 269 break;
8417 }
8418 case itype_bomb:
8419 {
8420 285 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8421 285 tempitem.misc4 = 0;
8422 285 tempitem.misc5 = 0;
8423 285 tempitem.misc6 = 0;
8424 285 tempitem.misc7 = 0;
8425 285 tempitem.misc8 = 0;
8426 285 tempitem.misc9 = 0;
8427 285 tempitem.misc10 = 0;
8428 285 tempitem.wpn3 = 0;
8429 285 tempitem.wpn4 = 0;
8430 285 tempitem.wpn5 = 0;
8431 285 tempitem.wpn6 = 0;
8432 285 tempitem.wpn7 = 0;
8433 285 tempitem.wpn8 = 0;
8434 285 tempitem.wpn9 = 0;
8435 285 tempitem.wpn10 = 0;
8436 285 break;
8437 }
8438 case itype_sbomb:
8439 {
8440 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8441 271 tempitem.misc4 = 0;
8442 271 tempitem.misc5 = 0;
8443 271 tempitem.misc6 = 0;
8444 271 tempitem.misc7 = 0;
8445 271 tempitem.misc8 = 0;
8446 271 tempitem.misc9 = 0;
8447 271 tempitem.misc10 = 0;
8448 271 tempitem.wpn3 = 0;
8449 271 tempitem.wpn4 = 0;
8450 271 tempitem.wpn5 = 0;
8451 271 tempitem.wpn6 = 0;
8452 271 tempitem.wpn7 = 0;
8453 271 tempitem.wpn8 = 0;
8454 271 tempitem.wpn9 = 0;
8455 271 tempitem.wpn10 = 0;
8456 271 break;
8457 }
8458 case itype_clock:
8459 {
8460 271 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8461 271 tempitem.misc2 = 0;
8462 271 tempitem.misc3 = 0;
8463 271 tempitem.misc4 = 0;
8464 271 tempitem.misc5 = 0;
8465 271 tempitem.misc6 = 0;
8466 271 tempitem.misc7 = 0;
8467 271 tempitem.misc8 = 0;
8468 271 tempitem.misc9 = 0;
8469 271 tempitem.misc10 = 0;
8470 271 tempitem.wpn = 0;
8471 271 tempitem.wpn2 = 0;
8472 271 tempitem.wpn3 = 0;
8473 271 tempitem.wpn4 = 0;
8474 271 tempitem.wpn5 = 0;
8475 271 tempitem.wpn6 = 0;
8476 271 tempitem.wpn7 = 0;
8477 271 tempitem.wpn8 = 0;
8478 271 tempitem.wpn9 = 0;
8479 271 tempitem.wpn10 = 0;
8480 271 break;
8481 }
8482 case itype_key:
8483 {
8484 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8485 269 tempitem.misc1 = 0;
8486 269 tempitem.misc2 = 0;
8487 269 tempitem.misc3 = 0;
8488 269 tempitem.misc4 = 0;
8489 269 tempitem.misc5 = 0;
8490 269 tempitem.misc6 = 0;
8491 269 tempitem.misc7 = 0;
8492 269 tempitem.misc8 = 0;
8493 269 tempitem.misc9 = 0;
8494 269 tempitem.misc10 = 0;
8495 269 tempitem.wpn = 0;
8496 269 tempitem.wpn2 = 0;
8497 269 tempitem.wpn3 = 0;
8498 269 tempitem.wpn4 = 0;
8499 269 tempitem.wpn5 = 0;
8500 269 tempitem.wpn6 = 0;
8501 269 tempitem.wpn7 = 0;
8502 269 tempitem.wpn8 = 0;
8503 269 tempitem.wpn9 = 0;
8504 269 tempitem.wpn10 = 0;
8505 269 break;
8506 }
8507 case itype_magiccontainer:
8508 {
8509 273 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8510 273 tempitem.misc1 = 0;
8511 273 tempitem.misc2 = 0;
8512 273 tempitem.misc3 = 0;
8513 273 tempitem.misc4 = 0;
8514 273 tempitem.misc5 = 0;
8515 273 tempitem.misc6 = 0;
8516 273 tempitem.misc7 = 0;
8517 273 tempitem.misc8 = 0;
8518 273 tempitem.misc9 = 0;
8519 273 tempitem.misc10 = 0;
8520 273 tempitem.wpn = 0;
8521 273 tempitem.wpn2 = 0;
8522 273 tempitem.wpn3 = 0;
8523 273 tempitem.wpn4 = 0;
8524 273 tempitem.wpn5 = 0;
8525 273 tempitem.wpn6 = 0;
8526 273 tempitem.wpn7 = 0;
8527 273 tempitem.wpn8 = 0;
8528 273 tempitem.wpn9 = 0;
8529 273 tempitem.wpn10 = 0;
8530 273 break;
8531 }
8532 case itype_triforcepiece:
8533 {
8534 538 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8535 538 tempitem.misc3 = 0;
8536 538 tempitem.misc4 = 0;
8537 538 tempitem.misc5 = 0;
8538 538 tempitem.misc6 = 0;
8539 538 tempitem.misc7 = 0;
8540 538 tempitem.misc8 = 0;
8541 538 tempitem.misc9 = 0;
8542 538 tempitem.misc10 = 0;
8543 538 tempitem.wpn = 0;
8544 538 tempitem.wpn2 = 0;
8545 538 tempitem.wpn3 = 0;
8546 538 tempitem.wpn4 = 0;
8547 538 tempitem.wpn5 = 0;
8548 538 tempitem.wpn6 = 0;
8549 538 tempitem.wpn7 = 0;
8550 538 tempitem.wpn8 = 0;
8551 538 tempitem.wpn9 = 0;
8552 538 tempitem.wpn10 = 0;
8553 538 break;
8554 }
8555 case itype_map: case itype_compass: case itype_bosskey:
8556 {
8557 811 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8558 811 tempitem.misc1 = 0;
8559 811 tempitem.misc2 = 0;
8560 811 tempitem.misc3 = 0;
8561 811 tempitem.misc4 = 0;
8562 811 tempitem.misc5 = 0;
8563 811 tempitem.misc6 = 0;
8564 811 tempitem.misc7 = 0;
8565 811 tempitem.misc8 = 0;
8566 811 tempitem.misc9 = 0;
8567 811 tempitem.misc10 = 0;
8568 811 tempitem.wpn = 0;
8569 811 tempitem.wpn2 = 0;
8570 811 tempitem.wpn3 = 0;
8571 811 tempitem.wpn4 = 0;
8572 811 tempitem.wpn5 = 0;
8573 811 tempitem.wpn6 = 0;
8574 811 tempitem.wpn7 = 0;
8575 811 tempitem.wpn8 = 0;
8576 811 tempitem.wpn9 = 0;
8577 811 tempitem.wpn10 = 0;
8578 811 break;
8579 }
8580 case itype_quiver:
8581 {
8582 1076 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8583 1076 tempitem.misc3 = 0;
8584 1076 tempitem.misc4 = 0;
8585 1076 tempitem.misc5 = 0;
8586 1076 tempitem.misc6 = 0;
8587 1076 tempitem.misc7 = 0;
8588 1076 tempitem.misc8 = 0;
8589 1076 tempitem.misc9 = 0;
8590 1076 tempitem.misc10 = 0;
8591 1076 tempitem.wpn = 0;
8592 1076 tempitem.wpn2 = 0;
8593 1076 tempitem.wpn3 = 0;
8594 1076 tempitem.wpn4 = 0;
8595 1076 tempitem.wpn5 = 0;
8596 1076 tempitem.wpn6 = 0;
8597 1076 tempitem.wpn7 = 0;
8598 1076 tempitem.wpn8 = 0;
8599 1076 tempitem.wpn9 = 0;
8600 1076 tempitem.wpn10 = 0;
8601 1076 break;
8602 }
8603 case itype_lkey:
8604 {
8605 759 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8606 759 tempitem.misc1 = 0;
8607 759 tempitem.misc2 = 0;
8608 759 tempitem.misc3 = 0;
8609 759 tempitem.misc4 = 0;
8610 759 tempitem.misc5 = 0;
8611 759 tempitem.misc6 = 0;
8612 759 tempitem.misc7 = 0;
8613 759 tempitem.misc8 = 0;
8614 759 tempitem.misc9 = 0;
8615 759 tempitem.misc10 = 0;
8616 759 tempitem.wpn = 0;
8617 759 tempitem.wpn2 = 0;
8618 759 tempitem.wpn3 = 0;
8619 759 tempitem.wpn4 = 0;
8620 759 tempitem.wpn5 = 0;
8621 759 tempitem.wpn6 = 0;
8622 759 tempitem.wpn7 = 0;
8623 759 tempitem.wpn8 = 0;
8624 759 tempitem.wpn9 = 0;
8625 759 tempitem.wpn10 = 0;
8626 759 break;
8627 }
8628 case itype_cbyrna:
8629 {
8630 269 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag5);
8631 269 tempitem.misc4 = 0;
8632 269 tempitem.misc5 = 0;
8633 269 tempitem.misc6 = 0;
8634 269 tempitem.misc7 = 0;
8635 269 tempitem.misc8 = 0;
8636 269 tempitem.misc9 = 0;
8637 269 tempitem.misc10 = 0;
8638 269 tempitem.wpn6 = 0;
8639 269 tempitem.wpn7 = 0;
8640 269 tempitem.wpn8 = 0;
8641 269 tempitem.wpn9 = 0;
8642 269 tempitem.wpn10 = 0;
8643 269 break;
8644 }
8645 case itype_rupee: case itype_arrowammo:
8646 {
8647 3150 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8648 3150 tempitem.misc1 = 0;
8649 3150 tempitem.misc2 = 0;
8650 3150 tempitem.misc3 = 0;
8651 3150 tempitem.misc4 = 0;
8652 3150 tempitem.misc5 = 0;
8653 3150 tempitem.misc6 = 0;
8654 3150 tempitem.misc7 = 0;
8655 3150 tempitem.misc8 = 0;
8656 3150 tempitem.misc9 = 0;
8657 3150 tempitem.misc10 = 0;
8658 3150 tempitem.wpn = 0;
8659 3150 tempitem.wpn2 = 0;
8660 3150 tempitem.wpn3 = 0;
8661 3150 tempitem.wpn4 = 0;
8662 3150 tempitem.wpn5 = 0;
8663 3150 tempitem.wpn6 = 0;
8664 3150 tempitem.wpn7 = 0;
8665 3150 tempitem.wpn8 = 0;
8666 3150 tempitem.wpn9 = 0;
8667 3150 tempitem.wpn10 = 0;
8668 3150 break;
8669 }
8670 case itype_fairy:
8671 {
8672 523 tempitem.flags &= ~ (item_flag3 | item_flag4 | item_flag5);
8673 523 tempitem.misc4 = 0;
8674 523 tempitem.misc5 = 0;
8675 523 tempitem.misc6 = 0;
8676 523 tempitem.misc7 = 0;
8677 523 tempitem.misc8 = 0;
8678 523 tempitem.misc9 = 0;
8679 523 tempitem.misc10 = 0;
8680 523 tempitem.wpn = 0;
8681 523 tempitem.wpn2 = 0;
8682 523 tempitem.wpn3 = 0;
8683 523 tempitem.wpn4 = 0;
8684 523 tempitem.wpn5 = 0;
8685 523 tempitem.wpn6 = 0;
8686 523 tempitem.wpn7 = 0;
8687 523 tempitem.wpn8 = 0;
8688 523 tempitem.wpn9 = 0;
8689 523 tempitem.wpn10 = 0;
8690 523 break;
8691 }
8692 case itype_magic: case itype_heart: case itype_heartcontainer: case itype_heartpiece: case itype_killem: case itype_bombammo:
8693 {
8694 2766 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8695 2766 tempitem.misc1 = 0;
8696 2766 tempitem.misc2 = 0;
8697 2766 tempitem.misc3 = 0;
8698 2766 tempitem.misc4 = 0;
8699 2766 tempitem.misc5 = 0;
8700 2766 tempitem.misc6 = 0;
8701 2766 tempitem.misc7 = 0;
8702 2766 tempitem.misc8 = 0;
8703 2766 tempitem.misc9 = 0;
8704 2766 tempitem.misc10 = 0;
8705 2766 tempitem.wpn = 0;
8706 2766 tempitem.wpn2 = 0;
8707 2766 tempitem.wpn3 = 0;
8708 2766 tempitem.wpn4 = 0;
8709 2766 tempitem.wpn5 = 0;
8710 2766 tempitem.wpn6 = 0;
8711 2766 tempitem.wpn7 = 0;
8712 2766 tempitem.wpn8 = 0;
8713 2766 tempitem.wpn9 = 0;
8714 2766 tempitem.wpn10 = 0;
8715 2766 break;
8716 }
8717 case itype_bombbag:
8718 {
8719 1076 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8720 1076 tempitem.misc3 = 0;
8721 1076 tempitem.misc4 = 0;
8722 1076 tempitem.misc5 = 0;
8723 1076 tempitem.misc6 = 0;
8724 1076 tempitem.misc7 = 0;
8725 1076 tempitem.misc8 = 0;
8726 1076 tempitem.misc9 = 0;
8727 1076 tempitem.misc10 = 0;
8728 1076 tempitem.wpn = 0;
8729 1076 tempitem.wpn2 = 0;
8730 1076 tempitem.wpn3 = 0;
8731 1076 tempitem.wpn4 = 0;
8732 1076 tempitem.wpn5 = 0;
8733 1076 tempitem.wpn6 = 0;
8734 1076 tempitem.wpn7 = 0;
8735 1076 tempitem.wpn8 = 0;
8736 1076 tempitem.wpn9 = 0;
8737 1076 tempitem.wpn10 = 0;
8738 1076 break;
8739 }
8740 case itype_rocs:
8741 {
8742 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8743 269 tempitem.misc1 = 0;
8744 269 tempitem.misc2 = 0;
8745 269 tempitem.misc3 = 0;
8746 269 tempitem.misc4 = 0;
8747 269 tempitem.misc5 = 0;
8748 269 tempitem.misc6 = 0;
8749 269 tempitem.misc7 = 0;
8750 269 tempitem.misc8 = 0;
8751 269 tempitem.misc9 = 0;
8752 269 tempitem.misc10 = 0;
8753 269 tempitem.wpn = 0;
8754 269 tempitem.wpn2 = 0;
8755 269 tempitem.wpn3 = 0;
8756 269 tempitem.wpn4 = 0;
8757 269 tempitem.wpn5 = 0;
8758 269 tempitem.wpn6 = 0;
8759 269 tempitem.wpn7 = 0;
8760 269 tempitem.wpn8 = 0;
8761 269 tempitem.wpn9 = 0;
8762 269 tempitem.wpn10 = 0;
8763 269 break;
8764 }
8765 case itype_hoverboots:
8766 {
8767 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8768 269 tempitem.misc2 = 0;
8769 269 tempitem.misc3 = 0;
8770 269 tempitem.misc4 = 0;
8771 269 tempitem.misc5 = 0;
8772 269 tempitem.misc6 = 0;
8773 269 tempitem.misc7 = 0;
8774 269 tempitem.misc8 = 0;
8775 269 tempitem.misc9 = 0;
8776 269 tempitem.misc10 = 0;
8777 269 tempitem.wpn2 = 0;
8778 269 tempitem.wpn3 = 0;
8779 269 tempitem.wpn4 = 0;
8780 269 tempitem.wpn5 = 0;
8781 269 tempitem.wpn6 = 0;
8782 269 tempitem.wpn7 = 0;
8783 269 tempitem.wpn8 = 0;
8784 269 tempitem.wpn9 = 0;
8785 269 tempitem.wpn10 = 0;
8786 269 break;
8787 }
8788 case itype_spinscroll:
8789 {
8790 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8791 269 tempitem.misc2 = 0;
8792 269 tempitem.misc3 = 0;
8793 269 tempitem.misc4 = 0;
8794 269 tempitem.misc5 = 0;
8795 269 tempitem.misc6 = 0;
8796 269 tempitem.misc7 = 0;
8797 269 tempitem.misc8 = 0;
8798 269 tempitem.misc9 = 0;
8799 269 tempitem.misc10 = 0;
8800 269 tempitem.wpn = 0;
8801 269 tempitem.wpn2 = 0;
8802 269 tempitem.wpn3 = 0;
8803 269 tempitem.wpn4 = 0;
8804 269 tempitem.wpn5 = 0;
8805 269 tempitem.wpn6 = 0;
8806 269 tempitem.wpn7 = 0;
8807 269 tempitem.wpn8 = 0;
8808 269 tempitem.wpn9 = 0;
8809 269 tempitem.wpn10 = 0;
8810 269 break;
8811 }
8812 case itype_crossscroll:
8813 {
8814 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8815 269 tempitem.misc1 = 0;
8816 269 tempitem.misc2 = 0;
8817 269 tempitem.misc3 = 0;
8818 269 tempitem.misc4 = 0;
8819 269 tempitem.misc5 = 0;
8820 269 tempitem.misc6 = 0;
8821 269 tempitem.misc7 = 0;
8822 269 tempitem.misc8 = 0;
8823 269 tempitem.misc9 = 0;
8824 269 tempitem.misc10 = 0;
8825 269 tempitem.wpn = 0;
8826 269 tempitem.wpn2 = 0;
8827 269 tempitem.wpn3 = 0;
8828 269 tempitem.wpn4 = 0;
8829 269 tempitem.wpn5 = 0;
8830 269 tempitem.wpn6 = 0;
8831 269 tempitem.wpn7 = 0;
8832 269 tempitem.wpn8 = 0;
8833 269 tempitem.wpn9 = 0;
8834 269 tempitem.wpn10 = 0;
8835 269 break;
8836 }
8837 case itype_quakescroll:
8838 {
8839 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8840 269 tempitem.misc3 = 0;
8841 269 tempitem.misc4 = 0;
8842 269 tempitem.misc5 = 0;
8843 269 tempitem.misc6 = 0;
8844 269 tempitem.misc7 = 0;
8845 269 tempitem.misc8 = 0;
8846 269 tempitem.misc9 = 0;
8847 269 tempitem.misc10 = 0;
8848 269 tempitem.wpn = 0;
8849 269 tempitem.wpn2 = 0;
8850 269 tempitem.wpn3 = 0;
8851 269 tempitem.wpn4 = 0;
8852 269 tempitem.wpn5 = 0;
8853 269 tempitem.wpn6 = 0;
8854 269 tempitem.wpn7 = 0;
8855 269 tempitem.wpn8 = 0;
8856 269 tempitem.wpn9 = 0;
8857 269 tempitem.wpn10 = 0;
8858 269 break;
8859 }
8860 case itype_whispring:
8861 {
8862 540 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8863 540 tempitem.misc2 = 0;
8864 540 tempitem.misc3 = 0;
8865 540 tempitem.misc4 = 0;
8866 540 tempitem.misc5 = 0;
8867 540 tempitem.misc6 = 0;
8868 540 tempitem.misc7 = 0;
8869 540 tempitem.misc8 = 0;
8870 540 tempitem.misc9 = 0;
8871 540 tempitem.misc10 = 0;
8872 540 tempitem.wpn = 0;
8873 540 tempitem.wpn2 = 0;
8874 540 tempitem.wpn3 = 0;
8875 540 tempitem.wpn4 = 0;
8876 540 tempitem.wpn5 = 0;
8877 540 tempitem.wpn6 = 0;
8878 540 tempitem.wpn7 = 0;
8879 540 tempitem.wpn8 = 0;
8880 540 tempitem.wpn9 = 0;
8881 540 tempitem.wpn10 = 0;
8882 540 break;
8883 }
8884 case itype_chargering:
8885 {
8886 538 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8887 538 tempitem.misc3 = 0;
8888 538 tempitem.misc4 = 0;
8889 538 tempitem.misc5 = 0;
8890 538 tempitem.misc6 = 0;
8891 538 tempitem.misc7 = 0;
8892 538 tempitem.misc8 = 0;
8893 538 tempitem.misc9 = 0;
8894 538 tempitem.misc10 = 0;
8895 538 tempitem.wpn = 0;
8896 538 tempitem.wpn2 = 0;
8897 538 tempitem.wpn3 = 0;
8898 538 tempitem.wpn4 = 0;
8899 538 tempitem.wpn5 = 0;
8900 538 tempitem.wpn6 = 0;
8901 538 tempitem.wpn7 = 0;
8902 538 tempitem.wpn8 = 0;
8903 538 tempitem.wpn9 = 0;
8904 538 tempitem.wpn10 = 0;
8905 538 break;
8906 }
8907 case itype_perilscroll:
8908 {
8909 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8910 269 tempitem.misc2 = 0;
8911 269 tempitem.misc3 = 0;
8912 269 tempitem.misc4 = 0;
8913 269 tempitem.misc5 = 0;
8914 269 tempitem.misc6 = 0;
8915 269 tempitem.misc7 = 0;
8916 269 tempitem.misc8 = 0;
8917 269 tempitem.misc9 = 0;
8918 269 tempitem.misc10 = 0;
8919 269 tempitem.wpn = 0;
8920 269 tempitem.wpn2 = 0;
8921 269 tempitem.wpn3 = 0;
8922 269 tempitem.wpn4 = 0;
8923 269 tempitem.wpn5 = 0;
8924 269 tempitem.wpn6 = 0;
8925 269 tempitem.wpn7 = 0;
8926 269 tempitem.wpn8 = 0;
8927 269 tempitem.wpn9 = 0;
8928 269 tempitem.wpn10 = 0;
8929 269 break;
8930 }
8931 case itype_wealthmedal:
8932 {
8933 809 tempitem.flags &= ~ (item_flag2 | item_flag3 | item_flag4 | item_flag5);
8934 809 tempitem.misc2 = 0;
8935 809 tempitem.misc3 = 0;
8936 809 tempitem.misc4 = 0;
8937 809 tempitem.misc5 = 0;
8938 809 tempitem.misc6 = 0;
8939 809 tempitem.misc7 = 0;
8940 809 tempitem.misc8 = 0;
8941 809 tempitem.misc9 = 0;
8942 809 tempitem.misc10 = 0;
8943 809 tempitem.wpn = 0;
8944 809 tempitem.wpn2 = 0;
8945 809 tempitem.wpn3 = 0;
8946 809 tempitem.wpn4 = 0;
8947 809 tempitem.wpn5 = 0;
8948 809 tempitem.wpn6 = 0;
8949 809 tempitem.wpn7 = 0;
8950 809 tempitem.wpn8 = 0;
8951 809 tempitem.wpn9 = 0;
8952 809 tempitem.wpn10 = 0;
8953 809 break;
8954 }
8955 case itype_heartring:
8956 {
8957 811 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8958 811 tempitem.misc3 = 0;
8959 811 tempitem.misc4 = 0;
8960 811 tempitem.misc5 = 0;
8961 811 tempitem.misc6 = 0;
8962 811 tempitem.misc7 = 0;
8963 811 tempitem.misc8 = 0;
8964 811 tempitem.misc9 = 0;
8965 811 tempitem.misc10 = 0;
8966 811 tempitem.wpn = 0;
8967 811 tempitem.wpn2 = 0;
8968 811 tempitem.wpn3 = 0;
8969 811 tempitem.wpn4 = 0;
8970 811 tempitem.wpn5 = 0;
8971 811 tempitem.wpn6 = 0;
8972 811 tempitem.wpn7 = 0;
8973 811 tempitem.wpn8 = 0;
8974 811 tempitem.wpn9 = 0;
8975 811 tempitem.wpn10 = 0;
8976 811 break;
8977 }
8978 case itype_magicring:
8979 {
8980 1084 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
8981 1084 tempitem.misc3 = 0;
8982 1084 tempitem.misc4 = 0;
8983 1084 tempitem.misc5 = 0;
8984 1084 tempitem.misc6 = 0;
8985 1084 tempitem.misc7 = 0;
8986 1084 tempitem.misc8 = 0;
8987 1084 tempitem.misc9 = 0;
8988 1084 tempitem.misc10 = 0;
8989 1084 tempitem.wpn = 0;
8990 1084 tempitem.wpn2 = 0;
8991 1084 tempitem.wpn3 = 0;
8992 1084 tempitem.wpn4 = 0;
8993 1084 tempitem.wpn5 = 0;
8994 1084 tempitem.wpn6 = 0;
8995 1084 tempitem.wpn7 = 0;
8996 1084 tempitem.wpn8 = 0;
8997 1084 tempitem.wpn9 = 0;
8998 1084 tempitem.wpn10 = 0;
8999 1084 break;
9000 }
9001 case itype_spinscroll2:
9002 {
9003 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9004 269 tempitem.misc2 = 0;
9005 269 tempitem.misc3 = 0;
9006 269 tempitem.misc4 = 0;
9007 269 tempitem.misc5 = 0;
9008 269 tempitem.misc6 = 0;
9009 269 tempitem.misc7 = 0;
9010 269 tempitem.misc8 = 0;
9011 269 tempitem.misc9 = 0;
9012 269 tempitem.misc10 = 0;
9013 269 tempitem.wpn = 0;
9014 269 tempitem.wpn2 = 0;
9015 269 tempitem.wpn3 = 0;
9016 269 tempitem.wpn4 = 0;
9017 269 tempitem.wpn5 = 0;
9018 269 tempitem.wpn6 = 0;
9019 269 tempitem.wpn7 = 0;
9020 269 tempitem.wpn8 = 0;
9021 269 tempitem.wpn9 = 0;
9022 269 tempitem.wpn10 = 0;
9023 269 break;
9024 }
9025 case itype_quakescroll2:
9026 {
9027 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9028 269 tempitem.misc3 = 0;
9029 269 tempitem.misc4 = 0;
9030 269 tempitem.misc5 = 0;
9031 269 tempitem.misc6 = 0;
9032 269 tempitem.misc7 = 0;
9033 269 tempitem.misc8 = 0;
9034 269 tempitem.misc9 = 0;
9035 269 tempitem.misc10 = 0;
9036 269 tempitem.wpn = 0;
9037 269 tempitem.wpn2 = 0;
9038 269 tempitem.wpn3 = 0;
9039 269 tempitem.wpn4 = 0;
9040 269 tempitem.wpn5 = 0;
9041 269 tempitem.wpn6 = 0;
9042 269 tempitem.wpn7 = 0;
9043 269 tempitem.wpn8 = 0;
9044 269 tempitem.wpn9 = 0;
9045 269 tempitem.wpn10 = 0;
9046 269 break;
9047 }
9048 case itype_agony:
9049 {
9050 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9051 269 tempitem.misc2 = 0;
9052 269 tempitem.misc3 = 0;
9053 269 tempitem.misc4 = 0;
9054 269 tempitem.misc5 = 0;
9055 269 tempitem.misc6 = 0;
9056 269 tempitem.misc7 = 0;
9057 269 tempitem.misc8 = 0;
9058 269 tempitem.misc9 = 0;
9059 269 tempitem.misc10 = 0;
9060 269 tempitem.wpn = 0;
9061 269 tempitem.wpn2 = 0;
9062 269 tempitem.wpn3 = 0;
9063 269 tempitem.wpn4 = 0;
9064 269 tempitem.wpn5 = 0;
9065 269 tempitem.wpn6 = 0;
9066 269 tempitem.wpn7 = 0;
9067 269 tempitem.wpn8 = 0;
9068 269 tempitem.wpn9 = 0;
9069 269 tempitem.wpn10 = 0;
9070 269 break;
9071 }
9072 case itype_stompboots:
9073 {
9074 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9075 269 tempitem.misc1 = 0;
9076 269 tempitem.misc2 = 0;
9077 269 tempitem.misc3 = 0;
9078 269 tempitem.misc4 = 0;
9079 269 tempitem.misc5 = 0;
9080 269 tempitem.misc6 = 0;
9081 269 tempitem.misc7 = 0;
9082 269 tempitem.misc8 = 0;
9083 269 tempitem.misc9 = 0;
9084 269 tempitem.misc10 = 0;
9085 269 tempitem.wpn = 0;
9086 269 tempitem.wpn2 = 0;
9087 269 tempitem.wpn3 = 0;
9088 269 tempitem.wpn4 = 0;
9089 269 tempitem.wpn5 = 0;
9090 269 tempitem.wpn6 = 0;
9091 269 tempitem.wpn7 = 0;
9092 269 tempitem.wpn8 = 0;
9093 269 tempitem.wpn9 = 0;
9094 269 tempitem.wpn10 = 0;
9095 269 break;
9096 }
9097 case itype_whimsicalring:
9098 {
9099 269 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9100 269 tempitem.misc2 = 0;
9101 269 tempitem.misc3 = 0;
9102 269 tempitem.misc4 = 0;
9103 269 tempitem.misc5 = 0;
9104 269 tempitem.misc6 = 0;
9105 269 tempitem.misc7 = 0;
9106 269 tempitem.misc8 = 0;
9107 269 tempitem.misc9 = 0;
9108 269 tempitem.misc10 = 0;
9109 269 tempitem.wpn = 0;
9110 269 tempitem.wpn2 = 0;
9111 269 tempitem.wpn3 = 0;
9112 269 tempitem.wpn4 = 0;
9113 269 tempitem.wpn5 = 0;
9114 269 tempitem.wpn6 = 0;
9115 269 tempitem.wpn7 = 0;
9116 269 tempitem.wpn8 = 0;
9117 269 tempitem.wpn9 = 0;
9118 269 tempitem.wpn10 = 0;
9119 269 break;
9120 }
9121 case itype_perilring:
9122 {
9123 295 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9124 295 tempitem.misc2 = 0;
9125 295 tempitem.misc3 = 0;
9126 295 tempitem.misc4 = 0;
9127 295 tempitem.misc5 = 0;
9128 295 tempitem.misc6 = 0;
9129 295 tempitem.misc7 = 0;
9130 295 tempitem.misc8 = 0;
9131 295 tempitem.misc9 = 0;
9132 295 tempitem.misc10 = 0;
9133 295 tempitem.wpn = 0;
9134 295 tempitem.wpn2 = 0;
9135 295 tempitem.wpn3 = 0;
9136 295 tempitem.wpn4 = 0;
9137 295 tempitem.wpn5 = 0;
9138 295 tempitem.wpn6 = 0;
9139 295 tempitem.wpn7 = 0;
9140 295 tempitem.wpn8 = 0;
9141 295 tempitem.wpn9 = 0;
9142 295 tempitem.wpn10 = 0;
9143 295 break;
9144 }
9145 case itype_custom1: case itype_custom2: case itype_custom3: case itype_custom4: case itype_custom5:
9146 case itype_custom6: case itype_custom7: case itype_custom8: case itype_custom9: case itype_custom10:
9147 case itype_custom11: case itype_custom12: case itype_custom13: case itype_custom14: case itype_custom15:
9148 case itype_custom16: case itype_custom17: case itype_custom18: case itype_custom19: case itype_custom20:
9149 case itype_bowandarrow: case itype_letterpotion: case itype_misc:
9150 {
9151 9413 tempitem.flags &= ~ (item_flag1 | item_flag2 | item_flag3 | item_flag4 | item_flag5);
9152 9413 tempitem.misc1 = 0;
9153 9413 tempitem.misc2 = 0;
9154 9413 tempitem.misc3 = 0;
9155 9413 tempitem.misc4 = 0;
9156 9413 tempitem.misc5 = 0;
9157 9413 tempitem.misc6 = 0;
9158 9413 tempitem.misc7 = 0;
9159 9413 tempitem.misc8 = 0;
9160 9413 tempitem.misc9 = 0;
9161 9413 tempitem.misc10 = 0;
9162 9413 tempitem.wpn = 0;
9163 9413 tempitem.wpn2 = 0;
9164 9413 tempitem.wpn3 = 0;
9165 9413 tempitem.wpn4 = 0;
9166 9413 tempitem.wpn5 = 0;
9167 9413 tempitem.wpn6 = 0;
9168 9413 tempitem.wpn7 = 0;
9169 9413 tempitem.wpn8 = 0;
9170 9413 tempitem.wpn9 = 0;
9171 9413 tempitem.wpn10 = 0;
9172 9413 break;
9173 }
9174 }
9175 69376 }
9176 //Port quest rules to items
9177
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version <= 31)
9178 {
9179
2/2
✓ Branch 0 taken 285 times.
✓ Branch 1 taken 69091 times.
69376 if(tempitem.family == itype_bomb)
9180 {
9181
2/2
✓ Branch 0 taken 155 times.
✓ Branch 1 taken 130 times.
285 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9182 130 else tempitem.flags &= ~ item_flag2;
9183 285 }
9184
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 68820 times.
69091 else if(tempitem.family == itype_sbomb)
9185 {
9186
2/2
✓ Branch 0 taken 157 times.
✓ Branch 1 taken 114 times.
271 if ( get_qr(qr_OUCHBOMBS) ) tempitem.flags |= item_flag2;
9187 114 else tempitem.flags &= ~ item_flag2;
9188 271 }
9189
9190
2/2
✓ Branch 0 taken 813 times.
✓ Branch 1 taken 68007 times.
68820 else if(tempitem.family == itype_brang)
9191 {
9192
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 813 times.
813 if ( get_qr(qr_BRANGPICKUP) ) tempitem.flags |= item_flag4;
9193 813 else tempitem.flags &= ~ item_flag4;
9194 813 }
9195
2/2
✓ Branch 0 taken 67720 times.
✓ Branch 1 taken 287 times.
68007 else if(tempitem.family == itype_wand)
9196 {
9197
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 268 times.
287 if ( get_qr(qr_NOWANDMELEE) ) tempitem.flags |= item_flag3;
9198 268 else tempitem.flags &= ~ item_flag3;
9199 287 }
9200 69376 }
9201
9202 //Port quest rules to items
9203
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version <= 37)
9204 {
9205
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 69105 times.
69376 if(tempitem.family == itype_flippers)
9206 {
9207
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 193 times.
271 if ( (get_qr(qr_NODIVING)) ) tempitem.flags |= item_flag1;
9208 193 else tempitem.flags &= ~ item_flag1;
9209 271 }
9210
2/2
✓ Branch 0 taken 51590 times.
✓ Branch 1 taken 17515 times.
69105 else if(tempitem.family == itype_sword)
9211 {
9212
2/2
✓ Branch 0 taken 462 times.
✓ Branch 1 taken 17053 times.
17515 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9213 17053 else tempitem.flags &= ~ item_flag5;
9214 17515 }
9215
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 51303 times.
51590 else if(tempitem.family == itype_wand)
9216 {
9217
2/2
✓ Branch 0 taken 10 times.
✓ Branch 1 taken 277 times.
287 if ( (get_qr(qr_QUICKSWORD)) ) tempitem.flags |= item_flag5;
9218 277 else tempitem.flags &= ~ item_flag5;
9219 287 }
9220
4/4
✓ Branch 0 taken 51018 times.
✓ Branch 1 taken 285 times.
✓ Branch 2 taken 580 times.
✓ Branch 3 taken 50438 times.
51303 else if(tempitem.family == itype_book || tempitem.family == itype_candle)
9221 {
9222 //@Emily: What was qrFIREPROOFHERO2 again, and does that also need to enable this?
9223
2/2
✓ Branch 0 taken 375 times.
✓ Branch 1 taken 490 times.
865 if ( (get_qr(qr_FIREPROOFHERO)) ) tempitem.flags |= item_flag3;
9224 490 else tempitem.flags &= ~ item_flag3;
9225 865 }
9226 69376 }
9227
9228
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 38)
9229 {
9230
4/4
✓ Branch 0 taken 68563 times.
✓ Branch 1 taken 813 times.
✓ Branch 2 taken 540 times.
✓ Branch 3 taken 68023 times.
69376 if(tempitem.family == itype_brang || tempitem.family == itype_hookshot)
9231 {
9232
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1353 times.
1353 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9233 1353 else tempitem.flags &= ~item_flag4;
9234
9235
2/2
✓ Branch 0 taken 672 times.
✓ Branch 1 taken 681 times.
1353 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags |= item_flag5 | item_flag6;
9236 681 else tempitem.flags &= ~(item_flag5|item_flag6);
9237 1353 }
9238
2/2
✓ Branch 0 taken 67222 times.
✓ Branch 1 taken 801 times.
68023 else if(tempitem.family == itype_arrow)
9239 {
9240
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 801 times.
801 if(get_qr(qr_BRANGPICKUP)) tempitem.flags |= item_flag4;
9241 801 else tempitem.flags &= ~item_flag4;
9242
9243
2/2
✓ Branch 0 taken 396 times.
✓ Branch 1 taken 405 times.
801 if(get_qr(qr_Z3BRANG_HSHOT)) tempitem.flags &= ~item_flag2;
9244 405 else tempitem.flags |= item_flag2;
9245 801 }
9246 69376 }
9247
9248
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 39)
9249 {
9250
6/6
✓ Branch 0 taken 69107 times.
✓ Branch 1 taken 269 times.
✓ Branch 2 taken 68822 times.
✓ Branch 3 taken 285 times.
✓ Branch 4 taken 580 times.
✓ Branch 5 taken 68242 times.
69376 if(tempitem.family == itype_divinefire || tempitem.family == itype_book || tempitem.family == itype_candle)
9251 {
9252
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 1118 times.
1134 if(get_qr(qr_TEMPCANDLELIGHT)) tempitem.flags |= item_flag5;
9253 1118 else tempitem.flags &= ~item_flag5;
9254 1134 }
9255
2/2
✓ Branch 0 taken 593 times.
✓ Branch 1 taken 67649 times.
68242 else if(tempitem.family == itype_potion)
9256 {
9257
2/2
✓ Branch 0 taken 162 times.
✓ Branch 1 taken 431 times.
593 if(get_qr(qr_NONBUBBLEMEDICINE))
9258 {
9259 162 tempitem.flags &= ~(item_flag3|item_flag4);
9260 162 }
9261 else
9262 {
9263 431 tempitem.flags |= item_flag3;
9264
2/2
✓ Branch 0 taken 121 times.
✓ Branch 1 taken 310 times.
431 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9265 310 else tempitem.flags &= ~item_flag4;
9266 }
9267 593 }
9268
2/2
✓ Branch 0 taken 67111 times.
✓ Branch 1 taken 538 times.
67649 else if(tempitem.family == itype_triforcepiece)
9269 {
9270
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 454 times.
538 if(get_qr(qr_NONBUBBLETRIFORCE))
9271 {
9272 84 tempitem.flags |= item_flag3;
9273
2/2
✓ Branch 0 taken 56 times.
✓ Branch 1 taken 28 times.
84 if(get_qr(qr_ITEMBUBBLE))tempitem.flags |= item_flag4;
9274 28 else tempitem.flags &= ~item_flag4;
9275 84 }
9276 else
9277 {
9278 454 tempitem.flags &= ~(item_flag3|item_flag4);
9279 }
9280 538 }
9281 69376 }
9282
9283
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 40)
9284 {
9285
4/4
✓ Branch 0 taken 68515 times.
✓ Branch 1 taken 861 times.
✓ Branch 2 taken 295 times.
✓ Branch 3 taken 68220 times.
69376 if(tempitem.family == itype_ring || tempitem.family == itype_perilring)
9286 {
9287
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 890 times.
1156 if(get_qr(qr_RINGAFFECTDAMAGE))tempitem.flags |= item_flag1;
9288 890 else tempitem.flags &= ~item_flag1;
9289 1156 }
9290
8/8
✓ Branch 0 taken 67640 times.
✓ Branch 1 taken 580 times.
✓ Branch 2 taken 50125 times.
✓ Branch 3 taken 17515 times.
✓ Branch 4 taken 49838 times.
✓ Branch 5 taken 287 times.
✓ Branch 6 taken 269 times.
✓ Branch 7 taken 49569 times.
68220 else if(tempitem.family == itype_candle || tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_cbyrna)
9291 {
9292
2/2
✓ Branch 0 taken 108 times.
✓ Branch 1 taken 18543 times.
18651 if(get_qr(qr_SLASHFLIPFIX))tempitem.flags |= item_flag8;
9293 18543 else tempitem.flags &= ~item_flag8;
9294 18651 }
9295
6/6
✓ Branch 0 taken 51861 times.
✓ Branch 1 taken 17515 times.
✓ Branch 2 taken 51574 times.
✓ Branch 3 taken 287 times.
✓ Branch 4 taken 271 times.
✓ Branch 5 taken 51303 times.
69376 if(tempitem.family == itype_sword || tempitem.family == itype_wand || tempitem.family == itype_hammer)
9296 {
9297
2/2
✓ Branch 0 taken 104 times.
✓ Branch 1 taken 17969 times.
18073 if(get_qr(qr_NOITEMMELEE))tempitem.flags |= item_flag7;
9298 17969 else tempitem.flags &= ~item_flag7;
9299 18073 }
9300
2/2
✓ Branch 0 taken 51034 times.
✓ Branch 1 taken 269 times.
51303 else if(tempitem.family == itype_cbyrna)
9301 {
9302 269 tempitem.flags |= item_flag7;
9303 269 }
9304 69376 }
9305
9306
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 41 )
9307 {
9308
2/2
✓ Branch 0 taken 51861 times.
✓ Branch 1 taken 17515 times.
69376 if(tempitem.family == itype_sword)
9309 {
9310
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 17327 times.
17515 if(get_qr(qr_SWORDMIRROR))tempitem.flags |= item_flag9;
9311 17327 else tempitem.flags &= ~item_flag9;
9312
9313
2/2
✓ Branch 0 taken 428 times.
✓ Branch 1 taken 17087 times.
17515 if(get_qr(qr_SLOWCHARGINGWALK))tempitem.flags |= item_flag10;
9314 17087 else tempitem.flags &= ~item_flag10;
9315 17515 }
9316 69376 }
9317
9318
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 42 )
9319 {
9320
2/2
✓ Branch 0 taken 287 times.
✓ Branch 1 taken 69089 times.
69376 if(tempitem.family == itype_wand)
9321 {
9322
2/2
✓ Branch 0 taken 19 times.
✓ Branch 1 taken 268 times.
287 if(get_qr(qr_NOWANDMELEE))tempitem.flags |= item_flag3;
9323 268 else tempitem.flags &= ~item_flag3;
9324
9325 287 tempitem.flags &= ~item_flag6;
9326 287 }
9327
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 68818 times.
69089 else if(tempitem.family == itype_hammer)
9328 {
9329 271 tempitem.flags &= ~item_flag3;
9330 271 }
9331
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 68549 times.
68818 else if(tempitem.family == itype_cbyrna)
9332 {
9333 269 tempitem.flags |= item_flag3;
9334
9335 269 tempitem.flags &= ~item_flag6;
9336 269 }
9337
2/2
✓ Branch 0 taken 51034 times.
✓ Branch 1 taken 17515 times.
68549 else if(tempitem.family == itype_sword)
9338 {
9339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 17515 times.
17515 if(get_qr(qr_MELEEMAGICCOST))tempitem.flags |= item_flag6;
9340 17515 else tempitem.flags &= ~item_flag6;
9341 17515 }
9342 69376 }
9343
9344
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 43 )
9345 {
9346
2/2
✓ Branch 0 taken 69059 times.
✓ Branch 1 taken 317 times.
69376 if(tempitem.family == itype_whistle)
9347 {
9348
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 309 times.
317 if(get_qr(qr_WHIRLWINDMIRROR))tempitem.flags |= item_flag3;
9349 309 else tempitem.flags &= ~item_flag3;
9350 317 }
9351 69376 }
9352
9353
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 45 )
9354 {
9355
2/2
✓ Branch 0 taken 69105 times.
✓ Branch 1 taken 271 times.
69376 if(tempitem.family == itype_flippers)
9356 {
9357 271 tempitem.misc1 = 50; //Dive length, default 50 frames -V
9358 271 tempitem.misc2 = 30; //Dive cooldown, default 30 frames -V
9359 271 }
9360 69376 }
9361
9362
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 46 )
9363 {
9364
2/2
✓ Branch 0 taken 69107 times.
✓ Branch 1 taken 269 times.
69376 if(tempitem.family == itype_raft)
9365 {
9366 269 tempitem.misc1 = 1; //Rafting speed modifier; default 1. Negative slows, positive speeds.
9367 269 }
9368 69376 }
9369
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if ( s_version < 34 ) //! set the default counter for older quests.
9370 {
9371
2/2
✓ Branch 0 taken 106 times.
✓ Branch 1 taken 69270 times.
69376 if ( (tempitem.flags & item_rupee_magic) )
9372 {
9373 106 tempitem.cost_counter[0] = 1;
9374 106 }
9375 else
9376 {
9377
2/2
✓ Branch 0 taken 42240 times.
✓ Branch 1 taken 27030 times.
69270 if(get_qr(qr_ENABLEMAGIC))
9378 42240 tempitem.cost_counter[0] = 4;
9379 else
9380 {
9381 27030 tempitem.cost_amount[0] = 0;
9382 27030 tempitem.cost_counter[0] = -1;
9383 }
9384 }
9385 69376 }
9386
9387
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if ( s_version < 35 ) //new Lens of Truth flags
9388 {
9389
2/2
✓ Branch 0 taken 69131 times.
✓ Branch 1 taken 245 times.
69376 if ( tempitem.family == itype_lens )
9390 {
9391
2/2
✓ Branch 0 taken 237 times.
✓ Branch 1 taken 8 times.
245 if ( get_qr(qr_RAFTLENS) )
9392 {
9393 8 tempitem.flags |= item_flag4;
9394 8 }
9395
2/2
✓ Branch 0 taken 79 times.
✓ Branch 1 taken 166 times.
245 if ( get_qr(qr_LENSHINTS) )
9396 {
9397 166 tempitem.flags |= item_flag1;
9398 166 }
9399
2/2
✓ Branch 0 taken 234 times.
✓ Branch 1 taken 11 times.
245 if ( get_qr(qr_LENSSEESENEMIES) )
9400 {
9401 11 tempitem.flags |= item_flag5;
9402 11 }
9403 245 }
9404 69376 }
9405
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if ( s_version < 44 ) //InitD Labels and Sprite Script Data
9406 {
9407
2/2
✓ Branch 0 taken 555008 times.
✓ Branch 1 taken 69376 times.
624384 for ( int32_t q = 0; q < 8; q++ )
9408 {
9409 555008 sprintf(tempitem.initD_label[q],"InitD[%d]",q);
9410 555008 sprintf(tempitem.weapon_initD_label[q],"InitD[%d]",q);
9411 555008 sprintf(tempitem.sprite_initD_label[q],"InitD[%d]",q);
9412 555008 tempitem.sprite_initiald[q] = 0;
9413 555008 }
9414
2/2
✓ Branch 0 taken 138752 times.
✓ Branch 1 taken 69376 times.
208128 for ( int32_t q = 0; q < 2; q++ ) tempitem.sprite_initiala[q] = 0;
9415 69376 tempitem.sprite_script = 0;
9416 69376 }
9417
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if ( s_version < 47 ) //InitD Labels and Sprite Script Data
9418 {
9419 69376 tempitem.pickupflag = 0;
9420 69376 }
9421
9422
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 51 )
9423 {
9424
2/2
✓ Branch 0 taken 68796 times.
✓ Branch 1 taken 580 times.
69376 if( tempitem.family == itype_candle )
9425 {
9426 580 tempitem.misc4 = 50; //Step speed
9427 580 }
9428 69376 }
9429
9430
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if( s_version < 52 )
9431 {
9432
2/2
✓ Branch 0 taken 68555 times.
✓ Branch 1 taken 821 times.
69376 if( tempitem.family == itype_shield )
9433 821 tempitem.flags |= item_flag1; //'Block Front' flag
9434 69376 }
9435
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 69376 times.
177664 if(s_version < 53)
9436 {
9437
4/4
✓ Branch 0 taken 68019 times.
✓ Branch 1 taken 801 times.
✓ Branch 2 taken 285 times.
✓ Branch 3 taken 271 times.
69376 switch(tempitem.family)
9438 {
9439 case itype_arrow:
9440 801 tempitem.cost_counter[1] = crARROWS;
9441 801 tempitem.cost_amount[1] = 1;
9442 801 break;
9443 case itype_bomb:
9444 285 tempitem.cost_counter[1] = crBOMBS;
9445 285 tempitem.cost_amount[1] = 1;
9446 285 break;
9447 case itype_sbomb:
9448 271 tempitem.cost_counter[1] = crSBOMBS;
9449 271 tempitem.cost_amount[1] = 1;
9450 271 break;
9451 default:
9452 68019 tempitem.cost_counter[1] = crNONE;
9453 68019 tempitem.cost_amount[1] = 0;
9454 68019 }
9455 69376 tempitem.magiccosttimer[1] = 0;
9456 69376 }
9457
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 72192 times.
177664 if( s_version < 54 )
9458 {
9459
2/2
✓ Branch 0 taken 71908 times.
✓ Branch 1 taken 284 times.
72192 if( tempitem.family == itype_flippers )
9460 284 tempitem.misc3 = INT_BTN_A; //'Block Front' flag
9461 72192 }
9462
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 72192 times.
177664 if(s_version < 55)
9463 {
9464
3/3
✓ Branch 0 taken 560 times.
✓ Branch 1 taken 560 times.
✓ Branch 2 taken 71072 times.
72192 switch(tempitem.family)
9465 {
9466 case itype_spinscroll:
9467 case itype_quakescroll:
9468 560 tempitem.usesound2 = WAV_ZN1CHARGE;
9469 560 break;
9470 case itype_spinscroll2:
9471 case itype_quakescroll2:
9472 560 tempitem.usesound2 = WAV_ZN1CHARGE2;
9473 560 break;
9474 }
9475 72192 }
9476
2/2
✓ Branch 0 taken 105472 times.
✓ Branch 1 taken 72192 times.
177664 if(s_version < 56)
9477 {
9478
4/4
✓ Branch 0 taken 71010 times.
✓ Branch 1 taken 280 times.
✓ Branch 2 taken 606 times.
✓ Branch 3 taken 296 times.
72192 switch(tempitem.family)
9479 {
9480 case itype_divinefire:
9481
2/2
✓ Branch 0 taken 269 times.
✓ Branch 1 taken 11 times.
280 SETFLAG(tempitem.flags, item_flag9, version < 0x255); //Strong Fire
9482
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 198 times.
280 SETFLAG(tempitem.flags, item_flag10, version < 0x250); //Magic Fire
9483 280 tempitem.flags |= item_flag11; //Divine Fire
9484 280 break;
9485 case itype_candle:
9486
2/2
✓ Branch 0 taken 302 times.
✓ Branch 1 taken 304 times.
606 SETFLAG(tempitem.flags, item_flag9, tempitem.fam_type > 1); //Strong Fire
9487 606 tempitem.flags &= ~item_flag10; //Magic Fire
9488 606 tempitem.flags &= ~item_flag11; //Divine Fire
9489 606 break;
9490 case itype_book:
9491 296 tempitem.flags |= item_flag9; //Strong Fire
9492 296 tempitem.flags |= item_flag10; //Magic Fire
9493 296 tempitem.flags &= ~item_flag11; //Divine Fire
9494 296 break;
9495 }
9496 72192 }
9497
9498
2/2
✓ Branch 0 taken 166676 times.
✓ Branch 1 taken 10988 times.
177664 if(tempitem.fam_type==0) // Always do this
9499 10988 tempitem.fam_type=1;
9500
9501 177664 memcpy(&itemsbuf[i], &tempitem, sizeof(itemdata));
9502 177664 }
9503
9504 694 return 0;
9505 695 }
9506
9507 static bool did_init_def_items = false;
9508 355194 void init_def_items()
9509 {
9510
2/2
✓ Branch 0 taken 354881 times.
✓ Branch 1 taken 313 times.
355194 if(did_init_def_items) return;
9511 313 did_init_def_items = true;
9512 313 default_items[3].cost_counter[1] = crBOMBS;
9513 313 default_items[13].cost_counter[1] = crARROWS;
9514 313 default_items[14].cost_counter[1] = crARROWS;
9515 313 default_items[48].cost_counter[1] = crSBOMBS;
9516 313 default_items[57].cost_counter[1] = crARROWS;
9517 355194 }
9518 355194 void reset_itembuf(itemdata *item, int32_t id)
9519 {
9520 355194 init_def_items();
9521
2/2
✓ Branch 0 taken 151533 times.
✓ Branch 1 taken 203661 times.
355194 if(id<iLast)
9522 {
9523 // Copy everything *EXCEPT* the tile, misc, cset, frames, speed, delay and ltm.
9524 203661 word tile = item->tile;
9525 203661 byte miscs = item->misc_flags, cset = item->csets, frames = item->frames, speed = item->speed, delay = item->delay;
9526 203661 int32_t ltm = item->ltm;
9527
9528 203661 memcpy(item,&default_items[id],sizeof(itemdata));
9529 203661 item->tile = tile;
9530 203661 item->misc_flags = miscs;
9531 203661 item->csets = cset;
9532 203661 item->frames = frames;
9533 203661 item->speed = speed;
9534 203661 item->delay = delay;
9535 203661 item->ltm = ltm;
9536 203661 }
9537 355194 }
9538
9539 89088 void reset_itemname(int32_t id)
9540 {
9541 89088 sprintf(item_string[id],"zz%03d",id);
9542
9543
2/2
✓ Branch 0 taken 39324 times.
✓ Branch 1 taken 49764 times.
89088 if(id < iLast)
9544 49764 strcpy(item_string[id],old_item_string[id]);
9545 89088 }
9546
9547 695 int32_t readweapons(PACKFILE *f, zquestheader *Header)
9548 {
9549
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_weapons);
9550
9551 695 word weapons_to_read=MAXWPNS;
9552 int32_t dummy;
9553 byte padding;
9554 wpndata tempweapon;
9555 695 word s_version=0, s_cversion=0;
9556
9557
9558
2/2
✓ Branch 0 taken 689 times.
✓ Branch 1 taken 6 times.
695 if(Header->zelda_version < 0x186)
9559 {
9560 6 weapons_to_read=64;
9561 6 }
9562
9563
2/2
✓ Branch 0 taken 689 times.
✓ Branch 1 taken 6 times.
695 if(Header->zelda_version < 0x185)
9564 {
9565 6 weapons_to_read=32;
9566 6 }
9567
9568
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 if(Header->zelda_version > 0x192)
9569 {
9570 671 weapons_to_read=0;
9571
9572 //section version info
9573
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_version,f))
9574 {
9575 return qe_invalid;
9576 }
9577
9578 671 FFCore.quest_format[vWeaponSprites] = s_version;
9579
9580
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_cversion,f))
9581 {
9582 return qe_invalid;
9583 }
9584
9585 //section size
9586
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&dummy,f))
9587 {
9588 return qe_invalid;
9589 }
9590
9591 //finally... section data
9592
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&weapons_to_read,f))
9593 {
9594 return qe_invalid;
9595 }
9596
9597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if (weapons_to_read > MAXWPNS)
9598 {
9599 return qe_invalid;
9600 }
9601 671 }
9602
9603
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 83 times.
695 if(s_version>2)
9604 {
9605
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 612 times.
157284 for(int32_t i=0; i<weapons_to_read; i++)
9606 {
9607 char tempname[64];
9608
9609
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if(!pfread(tempname, 64, f))
9610 {
9611 return qe_invalid;
9612 }
9613
9614 156672 weapon_string[i][0] = '\0';
9615 156672 strncat(weapon_string[i], tempname, 64 - 1);
9616 156672 }
9617
9618
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(s_version<4)
9619 {
9620 strcpy(weapon_string[iwHover],old_weapon_string[iwHover]);
9621 strcpy(weapon_string[wFIREMAGIC],old_weapon_string[wFIREMAGIC]);
9622 }
9623
9624
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(s_version<5)
9625 {
9626 strcpy(weapon_string[iwQuarterHearts],old_weapon_string[iwQuarterHearts]);
9627 }
9628
9629 /*
9630 if (s_version<6)
9631 {
9632 strcpy(weapon_string[iwSideRaft],old_weapon_string[iwSideRaft]);
9633 strcpy(weapon_string[iwSideLadder],old_weapon_string[iwSideLadder]);
9634 }
9635 */
9636 612 }
9637
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 82 times.
83 else if (!should_skip)
9638 {
9639
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXWPNS; i++)
9640 20992 reset_weaponname(i);
9641 82 }
9642
9643
2/2
✓ Branch 0 taken 165484 times.
✓ Branch 1 taken 695 times.
166179 for(int32_t i=0; i<weapons_to_read; i++)
9644 {
9645 165484 word oldtile = 0;
9646
2/2
✓ Branch 0 taken 107008 times.
✓ Branch 1 taken 58476 times.
165484 if (s_version < 8)
9647 {
9648
1/2
✓ Branch 0 taken 58476 times.
✗ Branch 1 not taken.
58476 if (!p_igetw(&oldtile, f))
9649 return qe_invalid;
9650 58476 }
9651
9652
1/2
✓ Branch 0 taken 165484 times.
✗ Branch 1 not taken.
165484 if(!p_getc(&tempweapon.misc,f))
9653 {
9654 return qe_invalid;
9655 }
9656
9657
1/2
✓ Branch 0 taken 165484 times.
✗ Branch 1 not taken.
165484 if(!p_getc(&tempweapon.csets,f))
9658 {
9659 return qe_invalid;
9660 }
9661
9662
1/2
✓ Branch 0 taken 165484 times.
✗ Branch 1 not taken.
165484 if(!p_getc(&tempweapon.frames,f))
9663 {
9664 return qe_invalid;
9665 }
9666
9667
1/2
✓ Branch 0 taken 165484 times.
✗ Branch 1 not taken.
165484 if(!p_getc(&tempweapon.speed,f))
9668 {
9669 return qe_invalid;
9670 }
9671
9672
1/2
✓ Branch 0 taken 165484 times.
✗ Branch 1 not taken.
165484 if(!p_getc(&tempweapon.type,f))
9673 {
9674 return qe_invalid;
9675 }
9676
9677
2/2
✓ Branch 0 taken 57196 times.
✓ Branch 1 taken 108288 times.
165484 if ( s_version >= 7 )
9678 {
9679
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetw(&tempweapon.script,f))
9680 {
9681 return qe_invalid;
9682 }
9683
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if(!p_igetl(&tempweapon.tile,f))
9684 {
9685 return qe_invalid;
9686 }
9687 108288 }
9688
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 57196 times.
165484 if ( s_version < 7 )
9689 {
9690 57196 tempweapon.tile = oldtile;
9691 57196 }
9692
9693
2/2
✓ Branch 0 taken 160684 times.
✓ Branch 1 taken 4800 times.
165484 if(Header->zelda_version < 0x193)
9694 {
9695
1/2
✓ Branch 0 taken 4800 times.
✗ Branch 1 not taken.
4800 if(!p_getc(&padding,f))
9696 {
9697 return qe_invalid;
9698 }
9699 4800 }
9700
9701
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 8812 times.
165484 if(s_version < 6)
9702 {
9703
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 8794 times.
8812 if(i==ewFIRETRAIL)
9704 {
9705 18 tempweapon.misc |= WF_BEHIND;
9706 18 }
9707 else
9708 8794 tempweapon.misc &= ~WF_BEHIND;
9709 8812 }
9710
9711
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 165228 times.
165484 if (!should_skip)
9712 165228 memcpy(&wpnsbuf[i], &tempweapon, sizeof(tempweapon));
9713 165484 }
9714
9715
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 694 times.
695 if (should_skip)
9716 1 return 0;
9717
9718
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 612 times.
694 if(s_version<2)
9719 {
9720 82 wpnsbuf[wSBOOM]=wpnsbuf[wBOOM];
9721 82 }
9722
9723
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 612 times.
694 if(s_version<5)
9724 {
9725 82 wpnsbuf[iwQuarterHearts].tile=1;
9726 82 wpnsbuf[iwQuarterHearts].csets=1;
9727 82 }
9728
9729
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
694 if(Header->zelda_version < 0x176)
9730 {
9731 wpnsbuf[iwSpawn] = *((wpndata*)(itemsbuf + iMisc1));
9732 wpnsbuf[iwDeath] = *((wpndata*)(itemsbuf + iMisc2));
9733 memset(&itemsbuf[iMisc1],0,sizeof(itemdata));
9734 memset(&itemsbuf[iMisc2],0,sizeof(itemdata));
9735 }
9736
9737
3/4
✓ Branch 0 taken 676 times.
✓ Branch 1 taken 18 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 5 times.
699 if((Header->zelda_version < 0x192)||
9738
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 671 times.
676 ((Header->zelda_version == 0x192)&&(Header->build<129)))
9739 {
9740 18 wpnsbuf[wHSCHAIN_V] = wpnsbuf[wHSCHAIN_H];
9741 18 }
9742
9743
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 671 times.
694 if((Header->zelda_version < 0x210))
9744 {
9745 23 wpnsbuf[wLSHEAD] = wpnsbuf[wHSHEAD];
9746 23 wpnsbuf[wLSCHAIN_H] = wpnsbuf[wHSCHAIN_H];
9747 23 wpnsbuf[wLSHANDLE] = wpnsbuf[wHSHANDLE];
9748 23 wpnsbuf[wLSCHAIN_V] = wpnsbuf[wHSCHAIN_V];
9749 23 }
9750
9751 694 return 0;
9752 695 }
9753
9754 694 void init_guys(int32_t guyversion)
9755 {
9756
2/2
✓ Branch 0 taken 355328 times.
✓ Branch 1 taken 694 times.
356022 for(int32_t i=0; i<MAXGUYS; i++)
9757 {
9758 355328 guysbuf[i] = default_guys[0];
9759 355328 }
9760
9761
2/2
✓ Branch 0 taken 122838 times.
✓ Branch 1 taken 694 times.
123532 for(int32_t i=0; i<OLDMAXGUYS; i++)
9762 {
9763 122838 guysbuf[i] = default_guys[i];
9764
2/2
✓ Branch 0 taken 121450 times.
✓ Branch 1 taken 1388 times.
122838 guysbuf[i].spr_shadow = (guysbuf[i].family==eeROCK && guysbuf[i].attributes[9] == 1) ? iwLargeShadow : iwShadow;
9765 122838 guysbuf[i].spr_death = iwDeath;
9766 122838 guysbuf[i].spr_spawn = iwSpawn;
9767 // Patra fix: 2.10 BSPatras used spDIG. 2.50 Patras use CSet 7.
9768
4/4
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 108324 times.
✓ Branch 2 taken 14432 times.
✓ Branch 3 taken 82 times.
122838 if(guyversion<=3 && i==ePATRABS)
9769 {
9770 82 guysbuf[i].bosspal=spDIG;
9771 82 guysbuf[i].cset=14;
9772 82 guysbuf[i].attributes[8] = 14;
9773 82 }
9774
9775
2/2
✓ Branch 0 taken 108324 times.
✓ Branch 1 taken 14514 times.
122838 if(guyversion<=3)
9776 {
9777 // Rope/Ghini Flash rules
9778
2/2
✓ Branch 0 taken 4071 times.
✓ Branch 1 taken 10443 times.
14514 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
9779 {
9780
2/2
✓ Branch 0 taken 10384 times.
✓ Branch 1 taken 59 times.
10443 if(i==eROPE2)
9781 {
9782 59 guysbuf[i].flags &= ~guy_flashing;
9783 59 }
9784 10443 }
9785
9786
2/2
✓ Branch 0 taken 12390 times.
✓ Branch 1 taken 2124 times.
14514 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
9787 {
9788
12/12
✓ Branch 0 taken 2112 times.
✓ Branch 1 taken 12 times.
✓ Branch 2 taken 2100 times.
✓ Branch 3 taken 12 times.
✓ Branch 4 taken 2088 times.
✓ Branch 5 taken 12 times.
✓ Branch 6 taken 2076 times.
✓ Branch 7 taken 12 times.
✓ Branch 8 taken 2064 times.
✓ Branch 9 taken 12 times.
✓ Branch 10 taken 12 times.
✓ Branch 11 taken 2052 times.
2124 if(i==eBUBBLEST || i==eBUBBLESP || i==eBUBBLESR || i==eBUBBLEIT || i==eBUBBLEIP || i==eBUBBLEIR)
9789 {
9790 72 guysbuf[i].flags &= ~guy_flashing;
9791 72 }
9792 2124 }
9793
9794
2/2
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
14514 if(i==eGHINI2)
9795 {
9796
2/2
✓ Branch 0 taken 78 times.
✓ Branch 1 taken 4 times.
82 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
9797 {
9798 4 guysbuf[i].flags |= guy_blinking;
9799 4 }
9800
9801
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 38 times.
82 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
9802 {
9803 38 guysbuf[i].flags |= guy_transparent;
9804 38 }
9805 82 }
9806
9807
4/4
✓ Branch 0 taken 14432 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 14350 times.
14514 if (i == eDIG1 || i == eDIG3)
9808 {
9809 164 guysbuf[i].flags |= guy_ignore_kill_all;
9810 164 }
9811 14514 }
9812
9813 // Darknut fix
9814
10/10
✓ Branch 0 taken 122144 times.
✓ Branch 1 taken 694 times.
✓ Branch 2 taken 121450 times.
✓ Branch 3 taken 694 times.
✓ Branch 4 taken 120756 times.
✓ Branch 5 taken 694 times.
✓ Branch 6 taken 120062 times.
✓ Branch 7 taken 694 times.
✓ Branch 8 taken 694 times.
✓ Branch 9 taken 119368 times.
122838 if(i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)
9815 {
9816
2/2
✓ Branch 0 taken 3110 times.
✓ Branch 1 taken 360 times.
3470 if(get_qr(qr_NEWENEMYTILES))
9817 {
9818 3110 guysbuf[i].s_tile=guysbuf[i].e_tile+120;
9819 3110 guysbuf[i].s_width=guysbuf[i].e_width;
9820 3110 guysbuf[i].s_height=guysbuf[i].e_height;
9821 3110 }
9822 360 else guysbuf[i].s_tile=860;
9823
9824
2/2
✓ Branch 0 taken 3060 times.
✓ Branch 1 taken 410 times.
3470 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
9825 {
9826 410 guysbuf[i].flags |= guy_bkshield;
9827 410 }
9828 3470 }
9829
9830
4/4
✓ Branch 0 taken 122144 times.
✓ Branch 1 taken 694 times.
✓ Branch 2 taken 122788 times.
✓ Branch 3 taken 50 times.
122838 if((i==eGELTRIB || i==eFGELTRIB) && get_bit(deprecated_rules,qr_OLDTRIBBLES_DEP))
9831 {
9832 50 guysbuf[i].attributes[2] = (i == eFGELTRIB ? eFZOL : eZOL);
9833 50 }
9834 122838 }
9835 694 }
9836
9837 20992 void reset_weaponname(int32_t i)
9838 {
9839
2/2
✓ Branch 0 taken 7216 times.
✓ Branch 1 taken 13776 times.
20992 if(i<wLast)
9840 {
9841 7216 strcpy(weapon_string[i],old_weapon_string[i]);
9842 7216 }
9843 else
9844 13776 sprintf(weapon_string[i],"zz%03d",i);
9845 20992 }
9846
9847 694 void init_item_drop_sets()
9848 {
9849
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
9850 {
9851 // item_drop_sets[i] = default_item_drop_sets[0];
9852 177664 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
9853 177664 }
9854
9855
2/2
✓ Branch 0 taken 9022 times.
✓ Branch 1 taken 694 times.
9716 for(int32_t i=0; i<isMAX; i++)
9856 {
9857 9022 item_drop_sets[i] = default_item_drop_sets[i];
9858
9859 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
9860
2/2
✓ Branch 0 taken 90220 times.
✓ Branch 1 taken 9022 times.
99242 for(int32_t j=0; j<10; ++j)
9861 {
9862 90220 int32_t it = item_drop_sets[i].item[j];
9863
9864
3/4
✓ Branch 0 taken 63664 times.
✓ Branch 1 taken 26556 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4122 times.
90220 if((itemsbuf[it].family == itype_rupee && ((itemsbuf[it].amount)&0xFFF) == 10)
9865
2/2
✓ Branch 0 taken 4122 times.
✓ Branch 1 taken 59542 times.
63664 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
9866 {
9867 4122 item_drop_sets[i].chance[j+1]=0;
9868 4122 }
9869
4/4
✓ Branch 0 taken 2776 times.
✓ Branch 1 taken 83322 times.
✓ Branch 2 taken 144 times.
✓ Branch 3 taken 2632 times.
86098 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
9870 {
9871 144 item_drop_sets[i].chance[j+1]=0;
9872 144 }
9873
9874 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
9875
2/2
✓ Branch 0 taken 90196 times.
✓ Branch 1 taken 24 times.
90220 if(itemsbuf[it].family == itype_misc)
9876 {
9877 // If a non-gameplay item was selected, then item drop was aborted.
9878 // Reflect this by increasing the 'Nothing' chance accordingly.
9879 24 item_drop_sets[i].chance[0]+=item_drop_sets[i].chance[j+1];
9880 24 item_drop_sets[i].chance[j+1]=0;
9881 24 }
9882 90220 }
9883 9022 }
9884 694 }
9885
9886 694 void init_favorites()
9887 {
9888
2/2
✓ Branch 0 taken 874440 times.
✓ Branch 1 taken 694 times.
875134 for(int32_t i=0; i<MAXFAVORITECOMBOS; i++)
9889 {
9890 874440 favorite_combos[i]=-1;
9891 874440 }
9892 694 }
9893
9894 const char *ctype_name[cMAX]=
9895 {
9896 "cNONE", "cSTAIR", "cCAVE", "cWATER", "cARMOS", "cGRAVE", "cDOCK",
9897 "cUNDEF", "cPUSH_WAIT", "cPUSH_HEAVY", "cPUSH_HW", "cL_STATUE", "cR_STATUE",
9898 "cWALKSLOW", "cCVUP", "cCVDOWN", "cCVLEFT", "cCVRIGHT", "cSWIMWARP", "cDIVEWARP",
9899 "cLADDERHOOKSHOT", "cTRIGNOFLAG", "cTRIGFLAG", "cZELDA", "cSLASH", "cSLASHITEM",
9900 "cPUSH_HEAVY2", "cPUSH_HW2", "cPOUND", "cHSGRAB", "cHSBRIDGE", "cDAMAGE1",
9901 "cDAMAGE2", "cDAMAGE3", "cDAMAGE4", "cC_STATUE", "cTRAP_H", "cTRAP_V", "cTRAP_4",
9902 "cTRAP_LR", "cTRAP_UD", "cPIT", "cHOOKSHOTONLY", "cOVERHEAD", "cNOFLYZONE", "cMIRROR",
9903 "cMIRRORSLASH", "cMIRRORBACKSLASH", "cMAGICPRISM", "cMAGICPRISM4",
9904 "cMAGICSPONGE", "cCAVE2", "cEYEBALL_A", "cEYEBALL_B", "cNOJUMPZONE", "cBUSH",
9905 "cFLOWERS", "cTALLGRASS", "cSHALLOWWATER", "cLOCKBLOCK", "cLOCKBLOCK2",
9906 "cBOSSLOCKBLOCK", "cBOSSLOCKBLOCK2", "cLADDERONLY", "cBSGRAVE",
9907 "cCHEST", "cCHEST2", "cLOCKEDCHEST", "cLOCKEDCHEST2", "cBOSSCHEST", "cBOSSCHEST2",
9908 "cRESET", "cSAVE", "cSAVE2", "cCAVEB", "cCAVEC", "cCAVED",
9909 "cSTAIRB", "cSTAIRC", "cSTAIRD", "cPITB", "cPITC", "cPITD",
9910 "cCAVE2B", "cCAVE2C", "cCAVE2D", "cSWIMWARPB", "cSWIMWARPC", "cSWIMWARPD",
9911 "cDIVEWARPB", "cDIVEWARPC", "cDIVEWARPD", "cSTAIRR", "cPITR",
9912 "cAWARPA", "cAWARPB", "cAWARPC", "cAWARPD", "cAWARPR",
9913 "cSWARPA", "cSWARPB", "cSWARPC", "cSWARPD", "cSWARPR", "cSTRIGNOFLAG", "cSTRIGFLAG",
9914 "cSTEP", "cSTEPSAME", "cSTEPALL", "cSTEPCOPY", "cNOENEMY", "cBLOCKARROW1", "cBLOCKARROW2",
9915 "cBLOCKARROW3", "cBLOCKBRANG1", "cBLOCKBRANG2", "cBLOCKBRANG3", "cBLOCKSBEAM", "cBLOCKALL",
9916 "cBLOCKFIREBALL", "cDAMAGE5", "cDAMAGE6", "cDAMAGE7", "cCHANGE", "cSPINTILE1", "cSPINTILE2",
9917 "cSCREENFREEZE", "cSCREENFREEZEFF", "cNOGROUNDENEMY", "cSLASHNEXT", "cSLASHNEXTITEM", "cBUSHNEXT"
9918 "cSLASHTOUCHY", "cSLASHITEMTOUCHY", "cBUSHTOUCHY", "cFLOWERSTOUCHY", "cTALLGRASSTOUCHY",
9919 "cSLASHNEXTTOUCHY", "cSLASHNEXTITEMTOUCHY", "cBUSHNEXTTOUCHY", "cEYEBALL_4", "cTALLGRASSNEXT",
9920 "cSCRIPT1", "cSCRIPT2", "cSCRIPT3", "cSCRIPT4", "cSCRIPT5",
9921 "cSCRIPT6", "cSCRIPT7", "cSCRIPT8", "cSCRIPT9", "cSCRIPT10",
9922 "cSCRIPT11", "cSCRIPT12", "cSCRIPT13", "cSCRIPT14", "cSCRIPT15",
9923 "cSCRIPT16", "cSCRIPT17", "cSCRIPT18", "cSCRIPT19", "cSCRIPT20"
9924
9925 };
9926
9927 970 int32_t init_combo_classes()
9928 {
9929
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 970 times.
970 zinfo* zi = (load_tmp_zi ? load_tmp_zi : &ZI);
9930
2/2
✓ Branch 0 taken 177510 times.
✓ Branch 1 taken 970 times.
178480 for(int32_t i=0; i<cMAX; i++)
9931 {
9932 177510 combo_class_buf[i] = default_combo_classes[i];
9933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 177510 times.
177510 if ( char const* nm = zi->getComboTypeName(i) )
9934 {
9935 177510 size_t len = strlen(nm);
9936
2/2
✓ Branch 0 taken 11360640 times.
✓ Branch 1 taken 177510 times.
11538150 for ( size_t q = 0; q < 64; q++ )
9937 {
9938
2/2
✓ Branch 0 taken 2600570 times.
✓ Branch 1 taken 8760070 times.
11360640 combo_class_buf[i].name[q] = (q<len ? nm[q] : 0);
9939 11360640 }
9940 177510 }
9941 177510 }
9942
9943 970 return 0;
9944 }
9945
9946 294 int32_t readherosprites2(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
9947 {
9948
2/2
✓ Branch 0 taken 46 times.
✓ Branch 1 taken 248 times.
294 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_herosprites);
9949
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if (should_skip) return 0;
9950
9951
1/2
✓ Branch 0 taken 294 times.
✗ Branch 1 not taken.
294 assert(v_herosprites < 6);
9952 //these are here to bypass compiler warnings about unused arguments
9953 294 cv_herosprites=cv_herosprites;
9954
9955 294 zinit.hero_swim_speed=67; //default
9956 294 setupherotiles(zinit.heroAnimationStyle);
9957 294 setupherodefenses();
9958 294 setupherooffsets();
9959
9960
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 189 times.
294 if(v_herosprites>=0)
9961 {
9962 word tile, tile2;
9963 byte flip, extend, dummy_byte;
9964
9965
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
9966 {
9967
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
9968 {
9969 return qe_invalid;
9970 }
9971
9972
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
9973 {
9974 return qe_invalid;
9975 }
9976
9977
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
9978 {
9979 return qe_invalid;
9980 }
9981
9982 756 walkspr[i][spr_tile]=(int32_t)tile;
9983 756 walkspr[i][spr_flip]=(int32_t)flip;
9984 756 walkspr[i][spr_extend]=(int32_t)extend;
9985 756 }
9986
9987
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
9988 {
9989
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
9990 {
9991 return qe_invalid;
9992 }
9993
9994
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
9995 {
9996 return qe_invalid;
9997 }
9998
9999
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10000 {
10001 return qe_invalid;
10002 }
10003
10004 756 stabspr[i][spr_tile]=(int32_t)tile;
10005 756 stabspr[i][spr_flip]=(int32_t)flip;
10006 756 stabspr[i][spr_extend]=(int32_t)extend;
10007 756 }
10008
10009
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10010 {
10011
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10012 {
10013 return qe_invalid;
10014 }
10015
10016
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10017 {
10018 return qe_invalid;
10019 }
10020
10021
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10022 {
10023 return qe_invalid;
10024 }
10025
10026 756 slashspr[i][spr_tile]=(int32_t)tile;
10027 756 slashspr[i][spr_flip]=(int32_t)flip;
10028 756 slashspr[i][spr_extend]=(int32_t)extend;
10029 756 }
10030
10031
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10032 {
10033
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10034 {
10035 return qe_invalid;
10036 }
10037
10038
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10039 {
10040 return qe_invalid;
10041 }
10042
10043
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10044 {
10045 return qe_invalid;
10046 }
10047
10048 756 floatspr[i][spr_tile]=(int32_t)tile;
10049 756 floatspr[i][spr_flip]=(int32_t)flip;
10050 756 floatspr[i][spr_extend]=(int32_t)extend;
10051 756 }
10052
10053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>1)
10054 {
10055
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10056 {
10057
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10058 {
10059 return qe_invalid;
10060 }
10061
10062
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10063 {
10064 return qe_invalid;
10065 }
10066
10067
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10068 {
10069 return qe_invalid;
10070 }
10071
10072 756 swimspr[i][spr_tile]=(int32_t)tile;
10073 756 swimspr[i][spr_flip]=(int32_t)flip;
10074 756 swimspr[i][spr_extend]=(int32_t)extend;
10075 756 }
10076 189 }
10077
10078
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10079 {
10080
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10081 {
10082 return qe_invalid;
10083 }
10084
10085
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10086 {
10087 return qe_invalid;
10088 }
10089
10090
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10091 {
10092 return qe_invalid;
10093 }
10094
10095 756 divespr[i][spr_tile]=(int32_t)tile;
10096 756 divespr[i][spr_flip]=(int32_t)flip;
10097 756 divespr[i][spr_extend]=(int32_t)extend;
10098 756 }
10099
10100
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10101 {
10102
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10103 {
10104 return qe_invalid;
10105 }
10106
10107
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10108 {
10109 return qe_invalid;
10110 }
10111
10112
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10113 {
10114 return qe_invalid;
10115 }
10116
10117 756 poundspr[i][spr_tile]=(int32_t)tile;
10118 756 poundspr[i][spr_flip]=(int32_t)flip;
10119 756 poundspr[i][spr_extend]=(int32_t)extend;
10120 756 }
10121
10122
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_igetw(&tile,f))
10123 {
10124 return qe_invalid;
10125 }
10126
10127 189 flip=0;
10128
10129
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>0)
10130 {
10131
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&flip,f))
10132 {
10133 return qe_invalid;
10134 }
10135 189 }
10136
10137
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&extend,f))
10138 {
10139 return qe_invalid;
10140 }
10141
10142 189 castingspr[spr_tile]=(int32_t)tile;
10143 189 castingspr[spr_flip]=(int32_t)flip;
10144 189 castingspr[spr_extend]=(int32_t)extend;
10145
10146
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(v_herosprites>0)
10147 {
10148 189 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10149
2/2
✓ Branch 0 taken 378 times.
✓ Branch 1 taken 189 times.
567 for(int32_t i=0; i<2; i++)
10150 {
10151
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 378 times.
1134 for(int32_t j=0; j<num_holdsprs; j++)
10152 {
10153
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10154 {
10155 return qe_invalid;
10156 }
10157
10158
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10159 {
10160 return qe_invalid;
10161 }
10162
10163
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10164 {
10165 return qe_invalid;
10166 }
10167
10168 756 holdspr[i][j][spr_tile]=(int32_t)tile;
10169 756 holdspr[i][j][spr_flip]=(int32_t)flip;
10170 756 holdspr[i][j][spr_extend]=(int32_t)extend;
10171 756 }
10172 378 }
10173 189 }
10174 else
10175 {
10176 for(int32_t i=0; i<2; i++)
10177 {
10178 if(!p_igetw(&tile,f))
10179 {
10180 return qe_invalid;
10181 }
10182
10183 if(!p_igetw(&tile2,f))
10184 {
10185 return qe_invalid;
10186 }
10187
10188 if(!p_getc(&extend,f))
10189 {
10190 return qe_invalid;
10191 }
10192
10193 holdspr[i][spr_hold1][spr_tile]=(int32_t)tile;
10194 holdspr[i][spr_hold1][spr_flip]=(int32_t)flip;
10195 holdspr[i][spr_hold1][spr_extend]=(int32_t)extend;
10196 holdspr[i][spr_hold2][spr_tile]=(int32_t)tile2;
10197 holdspr[i][spr_hold2][spr_flip]=(int32_t)flip;
10198 holdspr[i][spr_hold2][spr_extend]=(int32_t)extend;
10199 }
10200 }
10201
10202
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>2)
10203 {
10204
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10205 {
10206
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10207 {
10208 return qe_invalid;
10209 }
10210
10211
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10212 {
10213 return qe_invalid;
10214 }
10215
10216
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&extend,f))
10217 {
10218 return qe_invalid;
10219 }
10220
10221 756 jumpspr[i][spr_tile]=(int32_t)tile;
10222 756 jumpspr[i][spr_flip]=(int32_t)flip;
10223 756 jumpspr[i][spr_extend]=(int32_t)extend;
10224 756 }
10225 189 }
10226
10227
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>3)
10228 {
10229
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i=0; i<4; i++)
10230 {
10231
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_igetw(&tile,f))
10232 {
10233 return qe_invalid;
10234 }
10235
10236
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if(!p_getc(&flip,f))
10237 {
10238 return qe_invalid;
10239 }
10240
10241
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 756 times.
756 if(!p_getc(&extend,f))
10242 {
10243 return qe_invalid;
10244 }
10245
10246 756 chargespr[i][spr_tile]=(int32_t)tile;
10247 756 chargespr[i][spr_flip]=(int32_t)flip;
10248 756 chargespr[i][spr_extend]=(int32_t)extend;
10249 756 }
10250 189 }
10251
10252
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(v_herosprites>4)
10253 {
10254
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&dummy_byte,f))
10255 {
10256 return qe_invalid;
10257 }
10258
10259 189 zinit.hero_swim_speed=(byte)dummy_byte;
10260 189 }
10261
10262 189 memset(frozenspr, 0, sizeof(frozenspr));
10263 189 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10264 189 memset(onfirespr, 0, sizeof(onfirespr));
10265 189 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10266 189 memset(diggingspr, 0, sizeof(diggingspr));
10267 189 memset(usingrodspr, 0, sizeof(usingrodspr));
10268 189 memset(usingcanespr, 0, sizeof(usingcanespr));
10269 189 memset(pushingspr, 0, sizeof(pushingspr));
10270 189 memset(liftingspr, 0, sizeof(liftingspr));
10271 189 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10272 189 memset(stunnedspr, 0, sizeof(stunnedspr));
10273 189 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10274 189 memset(fallingspr, 0, sizeof(fallingspr));
10275 189 memset(shockedspr, 0, sizeof(shockedspr));
10276 189 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10277 189 memset(pullswordspr, 0, sizeof(pullswordspr));
10278 189 memset(readingspr, 0, sizeof(readingspr));
10279 189 memset(slash180spr, 0, sizeof(slash180spr));
10280 189 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10281 189 memset(dashspr, 0, sizeof(dashspr));
10282 189 memset(bonkspr, 0, sizeof(bonkspr));
10283 189 memset(medallionsprs, 0, sizeof(medallionsprs));
10284 189 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10285 189 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10286
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t q = 0; q < 4; ++q)
10287 {
10288
2/2
✓ Branch 0 taken 2268 times.
✓ Branch 1 taken 756 times.
3024 for(int32_t p = 0; p < 3; ++p)
10289 {
10290 2268 drowningspr[q][p] = divespr[q][p];
10291 2268 drowning_lavaspr[q][p] = divespr[q][p];
10292 2268 }
10293 756 }
10294 189 memset(sideswimspr, 0, sizeof(sideswimspr));
10295 189 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
10296 189 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
10297 189 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
10298 189 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
10299 189 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
10300 189 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
10301 189 }
10302
10303
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 294 times.
294 if(FFCore.quest_format[vInitData] < 34)
10304 {
10305 294 bool fastswim = zinit.hero_swim_speed > 60;
10306 // '2/3' or '1/2'
10307 294 zinit.hero_swim_mult = fastswim ? 2 : 1;
10308 294 zinit.hero_swim_div = fastswim ? 3 : 2;
10309 294 }
10310 294 return 0;
10311 294 }
10312
10313 71910 void setSprite(int32_t* arr, int32_t tile, int32_t flip, int32_t ext)
10314 {
10315 71910 arr[spr_tile] = tile;
10316
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71910 times.
71910 arr[spr_flip] = (flip > 3 ? 0 : flip);
10317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 71910 times.
71910 arr[spr_extend] = (ext > 2 ? 0 : ext);
10318 71910 }
10319 //Used to read the player sprites as int32_t, not word.
10320 423 int32_t readherosprites3(PACKFILE *f, int32_t v_herosprites, int32_t cv_herosprites)
10321 {
10322 //these are here to bypass compiler warnings about unused arguments
10323 423 cv_herosprites=cv_herosprites;
10324
10325 423 zinit.hero_swim_speed=67; //default
10326 423 setupherotiles(zinit.heroAnimationStyle);
10327 423 setupherodefenses();
10328 423 setupherooffsets();
10329
10330 int32_t tile, tile2;
10331 byte flip, extend, dummy_byte;
10332
10333
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(v_herosprites>=0)
10334 {
10335
10336
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<4; i++)
10337 {
10338
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10339 {
10340 return qe_invalid;
10341 }
10342
10343
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10344 {
10345 return qe_invalid;
10346 }
10347
10348
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10349 {
10350 return qe_invalid;
10351 }
10352
10353 1692 setSprite(walkspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10354 1692 }
10355
10356
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<4; i++)
10357 {
10358
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10359 {
10360 return qe_invalid;
10361 }
10362
10363
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10364 {
10365 return qe_invalid;
10366 }
10367
10368
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10369 {
10370 return qe_invalid;
10371 }
10372
10373 1692 setSprite(stabspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10374 1692 }
10375
10376
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<4; i++)
10377 {
10378
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10379 {
10380 return qe_invalid;
10381 }
10382
10383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10384 {
10385 return qe_invalid;
10386 }
10387
10388
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10389 {
10390 return qe_invalid;
10391 }
10392
10393 1692 setSprite(slashspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10394 1692 }
10395
10396
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<4; i++)
10397 {
10398
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10399 {
10400 return qe_invalid;
10401 }
10402
10403
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10404 {
10405 return qe_invalid;
10406 }
10407
10408
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10409 {
10410 return qe_invalid;
10411 }
10412
10413 1692 setSprite(floatspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10414 1692 }
10415
10416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(v_herosprites>1)
10417 {
10418
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<4; i++)
10419 {
10420
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10421 {
10422 return qe_invalid;
10423 }
10424
10425
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10426 {
10427 return qe_invalid;
10428 }
10429
10430
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10431 {
10432 return qe_invalid;
10433 }
10434
10435 1692 setSprite(swimspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10436 1692 }
10437 423 }
10438
10439
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<4; i++)
10440 {
10441
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10442 {
10443 return qe_invalid;
10444 }
10445
10446
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10447 {
10448 return qe_invalid;
10449 }
10450
10451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10452 {
10453 return qe_invalid;
10454 }
10455
10456 1692 setSprite(divespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10457 1692 }
10458
10459
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<4; i++)
10460 {
10461
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10462 {
10463 return qe_invalid;
10464 }
10465
10466
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10467 {
10468 return qe_invalid;
10469 }
10470
10471
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10472 {
10473 return qe_invalid;
10474 }
10475
10476 1692 setSprite(poundspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10477 1692 }
10478
10479
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tile,f))
10480 {
10481 return qe_invalid;
10482 }
10483
10484 423 flip=0;
10485
10486
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(v_herosprites>0)
10487 {
10488
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&flip,f))
10489 {
10490 return qe_invalid;
10491 }
10492 423 }
10493
10494
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&extend,f))
10495 {
10496 return qe_invalid;
10497 }
10498
10499 423 setSprite(castingspr, int32_t(tile), int32_t(flip), int32_t(extend));
10500
10501
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(v_herosprites>0)
10502 {
10503 423 int32_t num_holdsprs = (v_herosprites > 6 ? 3 : 2);
10504
2/2
✓ Branch 0 taken 846 times.
✓ Branch 1 taken 423 times.
1269 for(int32_t i=0; i<2; i++)
10505 {
10506
2/2
✓ Branch 0 taken 2538 times.
✓ Branch 1 taken 846 times.
3384 for(int32_t j=0; j<num_holdsprs; j++)
10507 {
10508
1/2
✓ Branch 0 taken 2538 times.
✗ Branch 1 not taken.
2538 if(!p_igetl(&tile,f))
10509 {
10510 return qe_invalid;
10511 }
10512
10513
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_getc(&flip,f))
10514 {
10515 return qe_invalid;
10516 }
10517
10518
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2538 times.
2538 if(!p_getc(&extend,f))
10519 {
10520 return qe_invalid;
10521 }
10522
10523 2538 setSprite(holdspr[i][j], int32_t(tile), int32_t(flip), int32_t(extend));
10524 2538 }
10525 846 }
10526 423 }
10527 else
10528 {
10529 for(int32_t i=0; i<2; i++)
10530 {
10531 if(!p_igetl(&tile,f))
10532 {
10533 return qe_invalid;
10534 }
10535
10536 if(!p_igetl(&tile2,f))
10537 {
10538 return qe_invalid;
10539 }
10540
10541 if(!p_getc(&extend,f))
10542 {
10543 return qe_invalid;
10544 }
10545
10546 setSprite(holdspr[i][spr_hold1], int32_t(tile), int32_t(flip), int32_t(extend));
10547 setSprite(holdspr[i][spr_hold2], int32_t(tile2), int32_t(flip), int32_t(extend));
10548 }
10549 }
10550
10551
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(v_herosprites>2)
10552 {
10553
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<4; i++)
10554 {
10555
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10556 {
10557 return qe_invalid;
10558 }
10559
10560
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10561 {
10562 return qe_invalid;
10563 }
10564
10565
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10566 {
10567 return qe_invalid;
10568 }
10569
10570 1692 setSprite(jumpspr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10571 1692 }
10572 423 }
10573
10574
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(v_herosprites>3)
10575 {
10576
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t i=0; i<4; i++)
10577 {
10578
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10579 {
10580 return qe_invalid;
10581 }
10582
10583
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10584 {
10585 return qe_invalid;
10586 }
10587
10588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10589 {
10590 return qe_invalid;
10591 }
10592
10593 1692 setSprite(chargespr[i], int32_t(tile), int32_t(flip), int32_t(extend));
10594 1692 }
10595 423 }
10596
10597
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if(v_herosprites>4)
10598 {
10599
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&dummy_byte,f))
10600 {
10601 return qe_invalid;
10602 }
10603
10604 423 zinit.hero_swim_speed=(byte)dummy_byte;
10605 423 }
10606
10607
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(v_herosprites>6)
10608 {
10609
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10610 {
10611
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10612 return qe_invalid;
10613
10614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10615 return qe_invalid;
10616
10617
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10618 return qe_invalid;
10619
10620 1692 setSprite(frozenspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10621 1692 }
10622
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10623 {
10624
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10625 return qe_invalid;
10626
10627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10628 return qe_invalid;
10629
10630
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10631 return qe_invalid;
10632
10633 1692 setSprite(frozen_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10634 1692 }
10635
10636
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10637 {
10638
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10639 return qe_invalid;
10640
10641
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10642 return qe_invalid;
10643
10644
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10645 return qe_invalid;
10646
10647 1692 setSprite(onfirespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10648 1692 }
10649
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10650 {
10651
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10652 return qe_invalid;
10653
10654
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10655 return qe_invalid;
10656
10657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10658 return qe_invalid;
10659
10660 1692 setSprite(onfire_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10661 1692 }
10662
10663
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10664 {
10665
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10666 return qe_invalid;
10667
10668
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10669 return qe_invalid;
10670
10671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10672 return qe_invalid;
10673
10674 1692 setSprite(diggingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10675 1692 }
10676
10677
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10678 {
10679
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10680 return qe_invalid;
10681
10682
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10683 return qe_invalid;
10684
10685
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10686 return qe_invalid;
10687
10688 1692 setSprite(usingrodspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10689 1692 }
10690
10691
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10692 {
10693
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10694 return qe_invalid;
10695
10696
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10697 return qe_invalid;
10698
10699
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10700 return qe_invalid;
10701
10702 1692 setSprite(usingcanespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10703 1692 }
10704
10705
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10706 {
10707
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10708 return qe_invalid;
10709
10710
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10711 return qe_invalid;
10712
10713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10714 return qe_invalid;
10715
10716 1692 setSprite(pushingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10717 1692 }
10718
10719
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10720 {
10721
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10722 return qe_invalid;
10723
10724
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10725 return qe_invalid;
10726
10727
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10728 return qe_invalid;
10729
10730 1692 byte frames = 0;
10731
2/2
✓ Branch 0 taken 20 times.
✓ Branch 1 taken 1672 times.
1692 if(v_herosprites > 15)
10732 {
10733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1672 times.
1672 if(!p_getc(&frames,f))
10734 return qe_invalid;
10735 1672 }
10736
10737 1692 setSprite(liftingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10738 1692 liftingspr[q][spr_frames] = frames;
10739 1692 }
10740
10741
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10742 {
10743
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10744 return qe_invalid;
10745
10746
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10747 return qe_invalid;
10748
10749
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10750 return qe_invalid;
10751
10752 1692 setSprite(liftingwalkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10753 1692 }
10754
10755
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10756 {
10757
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_igetl(&tile,f))
10758 return qe_invalid;
10759
10760
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10761 return qe_invalid;
10762
10763
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10764 return qe_invalid;
10765
10766 1692 setSprite(stunnedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10767 1692 }
10768
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10769 {
10770
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10771 return qe_invalid;
10772
10773
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10774 return qe_invalid;
10775
10776
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10777 return qe_invalid;
10778
10779 1692 setSprite(stunned_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10780 1692 }
10781
10782
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10783 {
10784
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10785 return qe_invalid;
10786
10787
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10788 return qe_invalid;
10789
10790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10791 return qe_invalid;
10792
10793 1692 setSprite(drowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10794 1692 }
10795
10796
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10797 {
10798
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10799 return qe_invalid;
10800
10801
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10802 return qe_invalid;
10803
10804
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10805 return qe_invalid;
10806
10807 1692 setSprite(drowning_lavaspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10808 1692 }
10809
10810
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10811 {
10812
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10813 return qe_invalid;
10814
10815
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10816 return qe_invalid;
10817
10818
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10819 return qe_invalid;
10820
10821 1692 setSprite(fallingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10822 1692 }
10823
10824
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10825 {
10826
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10827 return qe_invalid;
10828
10829
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10830 return qe_invalid;
10831
10832
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10833 return qe_invalid;
10834
10835 1692 setSprite(shockedspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10836 1692 }
10837
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10838 {
10839
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10840 return qe_invalid;
10841
10842
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10843 return qe_invalid;
10844
10845
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10846 return qe_invalid;
10847
10848 1692 setSprite(shocked_waterspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10849 1692 }
10850
10851
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10852 {
10853
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10854 return qe_invalid;
10855
10856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10857 return qe_invalid;
10858
10859
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10860 return qe_invalid;
10861
10862 1692 setSprite(pullswordspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10863 1692 }
10864
10865
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10866 {
10867
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10868 return qe_invalid;
10869
10870
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10871 return qe_invalid;
10872
10873
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10874 return qe_invalid;
10875
10876 1692 setSprite(readingspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10877 1692 }
10878
10879
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10880 {
10881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_igetl(&tile,f))
10882 return qe_invalid;
10883
10884
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10885 return qe_invalid;
10886
10887
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10888 return qe_invalid;
10889
10890 1692 setSprite(slash180spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10891 1692 }
10892
10893
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10894 {
10895
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10896 return qe_invalid;
10897
10898
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10899 return qe_invalid;
10900
10901
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10902 return qe_invalid;
10903
10904 1692 setSprite(slashZ4spr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10905 1692 }
10906
10907
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10908 {
10909
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10910 return qe_invalid;
10911
10912
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10913 return qe_invalid;
10914
10915
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10916 return qe_invalid;
10917
10918 1692 setSprite(dashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10919 1692 }
10920
10921
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10922 {
10923
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10924 return qe_invalid;
10925
10926
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&flip,f))
10927 return qe_invalid;
10928
10929
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_getc(&extend,f))
10930 return qe_invalid;
10931
10932 1692 setSprite(bonkspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10933 1692 }
10934
10935
2/2
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 423 times.
1692 for(int32_t q = 0; q < 3; ++q) //Not directions; number of medallion sprs
10936 {
10937
1/2
✓ Branch 0 taken 1269 times.
✗ Branch 1 not taken.
1269 if(!p_igetl(&tile,f))
10938 return qe_invalid;
10939
10940
1/2
✓ Branch 0 taken 1269 times.
✗ Branch 1 not taken.
1269 if(!p_getc(&flip,f))
10941 return qe_invalid;
10942
10943
1/2
✓ Branch 0 taken 1269 times.
✗ Branch 1 not taken.
1269 if(!p_getc(&extend,f))
10944 return qe_invalid;
10945
10946 1269 setSprite(medallionsprs[q], int32_t(tile), int32_t(flip), int32_t(extend));
10947 1269 }
10948 423 }
10949 else
10950 {
10951 memset(frozenspr, 0, sizeof(frozenspr));
10952 memset(frozen_waterspr, 0, sizeof(frozen_waterspr));
10953 memset(onfirespr, 0, sizeof(onfirespr));
10954 memset(onfire_waterspr, 0, sizeof(onfire_waterspr));
10955 memset(diggingspr, 0, sizeof(diggingspr));
10956 memset(usingrodspr, 0, sizeof(usingrodspr));
10957 memset(usingcanespr, 0, sizeof(usingcanespr));
10958 memset(pushingspr, 0, sizeof(pushingspr));
10959 memset(liftingspr, 0, sizeof(liftingspr));
10960 memset(liftingwalkspr, 0, sizeof(liftingwalkspr));
10961 memset(stunnedspr, 0, sizeof(stunnedspr));
10962 memset(stunned_waterspr, 0, sizeof(stunned_waterspr));
10963 memset(fallingspr, 0, sizeof(fallingspr));
10964 memset(shockedspr, 0, sizeof(shockedspr));
10965 memset(shocked_waterspr, 0, sizeof(shocked_waterspr));
10966 memset(pullswordspr, 0, sizeof(pullswordspr));
10967 memset(readingspr, 0, sizeof(readingspr));
10968 memset(slash180spr, 0, sizeof(slash180spr));
10969 memset(slashZ4spr, 0, sizeof(slashZ4spr));
10970 memset(dashspr, 0, sizeof(dashspr));
10971 memset(bonkspr, 0, sizeof(bonkspr));
10972 memset(medallionsprs, 0, sizeof(medallionsprs));
10973 memset(holdspr[0][2], 0, sizeof(holdspr[0][2])); //Sword hold (Land)
10974 memset(holdspr[1][2], 0, sizeof(holdspr[1][2])); //Sword hold (Water)
10975 for(int32_t q = 0; q < 4; ++q)
10976 {
10977 for(int32_t p = 0; p < 3; ++p)
10978 {
10979 drowningspr[q][p] = divespr[q][p];
10980 drowning_lavaspr[q][p] = divespr[q][p];
10981 }
10982 }
10983 }
10984
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if (v_herosprites > 8)
10985 {
10986
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
10987 {
10988
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
10989 return qe_invalid;
10990
10991
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
10992 return qe_invalid;
10993
10994
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
10995 return qe_invalid;
10996
10997 1692 setSprite(sideswimspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
10998 1692 }
10999 423 }
11000 else
11001 {
11002 memset(sideswimspr, 0, sizeof(sideswimspr));
11003 }
11004
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if (v_herosprites > 9)
11005 {
11006
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
11007 {
11008
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
11009 return qe_invalid;
11010
11011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
11012 return qe_invalid;
11013
11014
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
11015 return qe_invalid;
11016
11017 1692 setSprite(sideswimslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11018 1692 }
11019
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
11020 {
11021
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
11022 return qe_invalid;
11023
11024
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
11025 return qe_invalid;
11026
11027
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
11028 return qe_invalid;
11029
11030 1692 setSprite(sideswimstabspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11031 1692 }
11032
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
11033 {
11034
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
11035 return qe_invalid;
11036
11037
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
11038 return qe_invalid;
11039
11040
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
11041 return qe_invalid;
11042
11043 1692 setSprite(sideswimpoundspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11044 1692 }
11045
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
11046 {
11047
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
11048 return qe_invalid;
11049
11050
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
11051 return qe_invalid;
11052
11053
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
11054 return qe_invalid;
11055
11056 1692 setSprite(sideswimchargespr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11057 1692 }
11058 423 }
11059 else
11060 {
11061 memset(sideswimslashspr, 0, sizeof(sideswimslashspr));
11062 memset(sideswimstabspr, 0, sizeof(sideswimstabspr));
11063 memset(sideswimpoundspr, 0, sizeof(sideswimpoundspr));
11064 memset(sideswimchargespr, 0, sizeof(sideswimchargespr));
11065 }
11066
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if (v_herosprites > 10)
11067 {
11068
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
11069 {
11070 int32_t hmr;
11071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_igetl(&hmr,f))
11072 return qe_invalid;
11073
11074 1692 hammeroffsets[q] = hmr;
11075 1692 }
11076 423 }
11077 else
11078 {
11079 for(int32_t q = 0; q < 4; ++q) hammeroffsets[q] = 0;
11080 }
11081
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if (v_herosprites > 11)
11082 {
11083
2/2
✓ Branch 0 taken 1269 times.
✓ Branch 1 taken 423 times.
1692 for(int32_t q = 0; q < 3; ++q)
11084 {
11085
1/2
✓ Branch 0 taken 1269 times.
✗ Branch 1 not taken.
1269 if(!p_igetl(&tile,f))
11086 return qe_invalid;
11087
11088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1269 times.
1269 if(!p_getc(&flip,f))
11089 return qe_invalid;
11090
11091
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1269 times.
1269 if(!p_getc(&extend,f))
11092 return qe_invalid;
11093
11094 1269 setSprite(sideswimholdspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11095 1269 }
11096 423 }
11097 else
11098 {
11099 memset(sideswimholdspr, 0, sizeof(sideswimholdspr));
11100 }
11101
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if (v_herosprites > 12)
11102 {
11103
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tile,f))
11104 return qe_invalid;
11105
11106
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&flip,f))
11107 return qe_invalid;
11108
11109
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_getc(&extend,f))
11110 return qe_invalid;
11111 423 setSprite(sideswimcastingspr, int32_t(tile), int32_t(flip), int32_t(extend));
11112
11113 423 }
11114 else
11115 {
11116 memset(sideswimcastingspr, 0, sizeof(sideswimcastingspr));
11117 }
11118
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if (v_herosprites > 13)
11119 {
11120
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
11121 {
11122
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
11123 return qe_invalid;
11124
11125
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
11126 return qe_invalid;
11127
11128
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
11129 return qe_invalid;
11130
11131 1692 setSprite(sidedrowningspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11132 1692 }
11133 423 }
11134 else
11135 {
11136 memset(sidedrowningspr, 0, sizeof(sidedrowningspr));
11137 }
11138
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if (v_herosprites > 14)
11139 {
11140
2/2
✓ Branch 0 taken 1692 times.
✓ Branch 1 taken 423 times.
2115 for(int32_t q = 0; q < 4; ++q)
11141 {
11142
1/2
✓ Branch 0 taken 1692 times.
✗ Branch 1 not taken.
1692 if(!p_igetl(&tile,f))
11143 return qe_invalid;
11144
11145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&flip,f))
11146 return qe_invalid;
11147
11148
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1692 times.
1692 if(!p_getc(&extend,f))
11149 return qe_invalid;
11150
11151 1692 setSprite(revslashspr[q], int32_t(tile), int32_t(flip), int32_t(extend));
11152 1692 }
11153 423 }
11154 else
11155 {
11156 memset(revslashspr, 0, sizeof(revslashspr));
11157 }
11158
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if (v_herosprites > 7)
11159 {
11160 423 int32_t num_defense = wMax;
11161 423 byte def = 0;
11162
11163 //Set num_defense accordingly if changes to enum require version upgrade - Jman
11164 /*if(v_herosprites > [x])
11165 * {
11166 * num_defense = 146 //value of wMax on version 8
11167 * }
11168 */
11169
11170
2/2
✓ Branch 0 taken 61758 times.
✓ Branch 1 taken 423 times.
62181 for (int32_t q = 0; q < num_defense; q++)
11171 {
11172
1/2
✓ Branch 0 taken 61758 times.
✗ Branch 1 not taken.
61758 if (!p_getc(&def, f))
11173 return qe_invalid;
11174
11175 61758 hero_defence[q] = def;
11176 61758 }
11177 423 }
11178 else
11179 {
11180 int32_t num_defense = wMax;
11181 for (int32_t q = 0; q < num_defense; q++)
11182 {
11183 hero_defence[q] = 0;
11184 }
11185 }
11186 423 }
11187
11188
2/2
✓ Branch 0 taken 412 times.
✓ Branch 1 taken 11 times.
423 if(FFCore.quest_format[vInitData] < 34)
11189 {
11190 11 bool fastswim = zinit.hero_swim_speed > 60;
11191 // '2/3' or '1/2'
11192 11 zinit.hero_swim_mult = fastswim ? 2 : 1;
11193 11 zinit.hero_swim_div = fastswim ? 3 : 2;
11194 11 }
11195 423 return 0;
11196 423 }
11197
11198
11199 612 int32_t readherosprites(PACKFILE *f, zquestheader *Header)
11200 {
11201 //these are here to bypass compiler warnings about unused arguments
11202 612 Header=Header;
11203
11204 dword dummy;
11205 612 word s_version=0, s_cversion=0;
11206
11207 //section version info
11208
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(!p_igetw(&s_version,f))
11209 {
11210 return qe_invalid;
11211 }
11212
11213 612 FFCore.quest_format[vHeroSprites] = s_version;
11214
11215
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&s_cversion,f))
11216 {
11217 return qe_invalid;
11218 }
11219
11220 //section size
11221
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetl(&dummy,f))
11222 {
11223 return qe_invalid;
11224 }
11225
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 189 times.
612 if ( s_version >= 6 )
11226 {
11227 423 return readherosprites3(f, s_version, dummy);
11228 }
11229 189 else return readherosprites2(f, s_version, dummy);
11230 612 }
11231
11232 207 int32_t read_old_subscreens(PACKFILE *f, word s_version)
11233 {
11234 207 subscreens_active.clear();
11235 207 subscreens_passive.clear();
11236 207 subscreens_overlay.clear();
11237
2/2
✓ Branch 0 taken 26496 times.
✓ Branch 1 taken 207 times.
26703 for(int32_t i=0; i<MAXCUSTOMSUBSCREENS; i++)
11238 {
11239 subscreen_group g;
11240 26496 memset(&g,0,sizeof(subscreen_group));
11241 26496 int32_t ret = read_one_old_subscreen(f, &g, s_version);
11242
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26496 times.
26496 if(ret!=0)
11243 return ret;
11244
2/2
✓ Branch 0 taken 1074 times.
✓ Branch 1 taken 25422 times.
26496 if(g.objects[0].type == ssoNULL) continue;
11245
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 624 times.
1074 auto& vec = g.ss_type == sstPASSIVE ? subscreens_passive : subscreens_active;
11246 1074 ZCSubscreen& sub = vec.emplace_back();
11247 1074 sub.load_old(g);
11248 1074 }
11249
11250 207 return 0;
11251 207 }
11252
11253 26496 int32_t read_one_old_subscreen(PACKFILE *f, subscreen_group* g, word s_version)
11254 {
11255 26496 int32_t numsub=0;
11256 26496 byte temp_ss=0;
11257 subscreen_object temp_sub_stack;
11258 26496 subscreen_object *temp_sub = &temp_sub_stack;
11259
11260 char tempname[64];
11261
11262 // FWIW I never saw anything bigger than 20.
11263 #define MAX_DP1_LEN 1024
11264 char tempdp1[MAX_DP1_LEN];
11265
11266
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26496 times.
26496 if(!pfread(tempname,64,f))
11267 {
11268 return qe_invalid;
11269 }
11270
11271
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26496 times.
26496 if(s_version > 1)
11272 {
11273
1/2
✓ Branch 0 taken 26496 times.
✗ Branch 1 not taken.
26496 if(!p_getc(&temp_ss,f))
11274 {
11275 return qe_invalid;
11276 }
11277 26496 }
11278
11279
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26496 times.
26496 if(s_version < 4)
11280 {
11281 uint8_t tmp=0;
11282
11283 if(!p_getc(&tmp,f))
11284 {
11285 return qe_invalid;
11286 }
11287
11288 numsub = (int32_t)tmp;
11289 }
11290 else
11291 {
11292 word tmp;
11293
11294
1/2
✓ Branch 0 taken 26496 times.
✗ Branch 1 not taken.
26496 if(!p_igetw(&tmp, f))
11295 {
11296 return qe_invalid;
11297 }
11298
11299 26496 numsub = (int32_t)tmp;
11300 }
11301
11302 int32_t j;
11303
11304
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 69602 times.
✓ Branch 2 taken 43106 times.
✓ Branch 3 taken 26496 times.
69602 for(j=0; (j<MAXSUBSCREENITEMS&&j<numsub); j++)
11305 {
11306 43106 memset(temp_sub,0,sizeof(subscreen_object));
11307
11308
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43106 times.
43106 switch(g->objects[j].type)
11309 {
11310 case ssoTEXT:
11311 case ssoTEXTBOX:
11312 case ssoCURRENTITEMTEXT:
11313 case ssoCURRENTITEMCLASSTEXT:
11314 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11315
11316 //fall through
11317 default:
11318 43106 memset(&g->objects[j],0,sizeof(subscreen_object));
11319 43106 break;
11320 }
11321
11322
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->type),f))
11323 return qe_invalid;
11324
11325
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->pos),f))
11326 return qe_invalid;
11327
11328
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(s_version < 5)
11329 {
11330 switch(temp_sub->pos)
11331 {
11332 case 0:
11333 temp_sub->pos = sspUP | sspDOWN | sspSCROLLING;
11334 break;
11335
11336 case 1:
11337 temp_sub->pos = sspUP;
11338 break;
11339
11340 case 2:
11341 temp_sub->pos = sspDOWN;
11342 break;
11343
11344 default:
11345 temp_sub->pos = 0;
11346 }
11347 }
11348
11349
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->x),f))
11350 return qe_invalid;
11351
11352
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->y),f))
11353 return qe_invalid;
11354
11355
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->w),f))
11356 return qe_invalid;
11357
11358
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->h),f))
11359 return qe_invalid;
11360
11361
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->colortype1),f))
11362 return qe_invalid;
11363
11364
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->color1),f))
11365 return qe_invalid;
11366
11367
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->colortype2),f))
11368 return qe_invalid;
11369
11370
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->color2),f))
11371 return qe_invalid;
11372
11373
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->colortype3),f))
11374 return qe_invalid;
11375
11376
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->color3),f))
11377 return qe_invalid;
11378
11379
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d1),f))
11380 return qe_invalid;
11381
11382
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d2),f))
11383 return qe_invalid;
11384
11385
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d3),f))
11386 return qe_invalid;
11387
11388
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d4),f))
11389 return qe_invalid;
11390
11391
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d5),f))
11392 return qe_invalid;
11393
11394
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d6),f))
11395 return qe_invalid;
11396
11397
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d7),f))
11398 return qe_invalid;
11399
11400
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d8),f))
11401 return qe_invalid;
11402
11403
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d9),f))
11404 return qe_invalid;
11405
11406
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetd(&(temp_sub->d10),f))
11407 return qe_invalid;
11408
11409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 43106 times.
43106 if(s_version < 2)
11410 {
11411 if(!p_igetl(&(temp_sub->speed),f))
11412 return qe_invalid;
11413
11414 if(!p_igetl(&(temp_sub->delay),f))
11415 return qe_invalid;
11416
11417 if(!p_igetl(&(temp_sub->frame),f))
11418 return qe_invalid;
11419 }
11420 else
11421 {
11422
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->speed),f))
11423 return qe_invalid;
11424
11425
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_getc(&(temp_sub->delay),f))
11426 return qe_invalid;
11427
11428
1/2
✓ Branch 0 taken 43106 times.
✗ Branch 1 not taken.
43106 if(!p_igetw(&(temp_sub->frame),f))
11429 return qe_invalid;
11430 }
11431
11432 43106 int32_t temp_size=0;
11433
11434 // bool deletets = false;
11435
4/4
✓ Branch 0 taken 18992 times.
✓ Branch 1 taken 3250 times.
✓ Branch 2 taken 20648 times.
✓ Branch 3 taken 216 times.
43106 switch(temp_sub->type)
11436 {
11437 case ssoTEXT:
11438 case ssoTEXTBOX:
11439 case ssoCURRENTITEMTEXT:
11440 case ssoCURRENTITEMCLASSTEXT:
11441 {
11442 word temptempsize;
11443
11444
1/2
✓ Branch 0 taken 3250 times.
✗ Branch 1 not taken.
3250 if(!p_igetw(&temptempsize,f))
11445 {
11446 return qe_invalid;
11447 }
11448
11449 //temptempsize = temp1 + (temp2 << 8);
11450 3250 temp_size = (int32_t)temptempsize;
11451 3250 uint32_t char_length = temp_size+2;
11452
1/2
✓ Branch 0 taken 3250 times.
✗ Branch 1 not taken.
3250 if (char_length > MAX_DP1_LEN)
11453 {
11454 return qe_invalid;
11455 }
11456 3250 tempdp1[char_length - 1] = '\0';
11457
11458
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3250 times.
3250 if(temp_size)
11459
1/2
✓ Branch 0 taken 3250 times.
✗ Branch 1 not taken.
3250 if(!pfread(tempdp1,temp_size+1,f))
11460 return qe_invalid;
11461 3250 break;
11462 }
11463
11464 case ssoLIFEMETER:
11465
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(get_bit(deprecated_rules, 12) != 0) // qr_24HC
11466 temp_sub->d3 = 1;
11467
11468
1/2
✓ Branch 0 taken 216 times.
✗ Branch 1 not taken.
216 if(!p_getc(&(temp_sub->dp1),f))
11469 return qe_invalid;
11470
11471 216 break;
11472
11473
11474 case ssoCURRENTITEM:
11475
11476
1/2
✓ Branch 0 taken 18992 times.
✗ Branch 1 not taken.
18992 if(s_version < 6)
11477 {
11478 switch(temp_sub->d1)
11479 {
11480 case ssiBOMB:
11481 temp_sub->d1 = itype_bomb;
11482 break;
11483
11484 case ssiSWORD:
11485 temp_sub->d1 = itype_sword;
11486 break;
11487
11488 case ssiSHIELD:
11489 temp_sub->d1 = itype_shield;
11490 break;
11491
11492 case ssiCANDLE:
11493 temp_sub->d1 = itype_candle;
11494 break;
11495
11496 case ssiLETTER:
11497 temp_sub->d1 = itype_letter;
11498 break;
11499
11500 case ssiPOTION:
11501 temp_sub->d1 = itype_potion;
11502 break;
11503
11504 case ssiLETTERPOTION:
11505 temp_sub->d1 = itype_letterpotion;
11506 break;
11507
11508 case ssiBOW:
11509 temp_sub->d1 = itype_bow;
11510 break;
11511
11512 case ssiARROW:
11513 temp_sub->d1 = itype_arrow;
11514 break;
11515
11516 case ssiBOWANDARROW:
11517 temp_sub->d1 = itype_bowandarrow;
11518 break;
11519
11520 case ssiBAIT:
11521 temp_sub->d1 = itype_bait;
11522 break;
11523
11524 case ssiRING:
11525 temp_sub->d1 = itype_ring;
11526 break;
11527
11528 case ssiBRACELET:
11529 temp_sub->d1 = itype_bracelet;
11530 break;
11531
11532 case ssiMAP:
11533 temp_sub->d1 = itype_map;
11534 break;
11535
11536 case ssiCOMPASS:
11537 temp_sub->d1 = itype_compass;
11538 break;
11539
11540 case ssiBOSSKEY:
11541 temp_sub->d1 = itype_bosskey;
11542 break;
11543
11544 case ssiMAGICKEY:
11545 temp_sub->d1 = itype_magickey;
11546 break;
11547
11548 case ssiBRANG:
11549 temp_sub->d1 = itype_brang;
11550 break;
11551
11552 case ssiWAND:
11553 temp_sub->d1 = itype_wand;
11554 break;
11555
11556 case ssiRAFT:
11557 temp_sub->d1 = itype_raft;
11558 break;
11559
11560 case ssiLADDER:
11561 temp_sub->d1 = itype_ladder;
11562 break;
11563
11564 case ssiWHISTLE:
11565 temp_sub->d1 = itype_whistle;
11566 break;
11567
11568 case ssiBOOK:
11569 temp_sub->d1 = itype_book;
11570 break;
11571
11572 case ssiWALLET:
11573 temp_sub->d1 = itype_wallet;
11574 break;
11575
11576 case ssiSBOMB:
11577 temp_sub->d1 = itype_sbomb;
11578 break;
11579
11580 case ssiHCPIECE:
11581 temp_sub->d1 = itype_heartpiece;
11582 break;
11583
11584 case ssiAMULET:
11585 temp_sub->d1 = itype_amulet;
11586 break;
11587
11588 case ssiFLIPPERS:
11589 temp_sub->d1 = itype_flippers;
11590 break;
11591
11592 case ssiHOOKSHOT:
11593 temp_sub->d1 = itype_hookshot;
11594 break;
11595
11596 case ssiLENS:
11597 temp_sub->d1 = itype_lens;
11598 break;
11599
11600 case ssiHAMMER:
11601 temp_sub->d1 = itype_hammer;
11602 break;
11603
11604 case ssiBOOTS:
11605 temp_sub->d1 = itype_boots;
11606 break;
11607
11608 case ssiDIVINEFIRE:
11609 temp_sub->d1 = itype_divinefire;
11610 break;
11611
11612 case ssiDIVINEESCAPE:
11613 temp_sub->d1 = itype_divineescape;
11614 break;
11615
11616 case ssiDIVINEPROTECTION:
11617 temp_sub->d1 = itype_divineprotection;
11618 break;
11619
11620 case ssiQUIVER:
11621 temp_sub->d1 = itype_quiver;
11622 break;
11623
11624 case ssiBOMBBAG:
11625 temp_sub->d1 = itype_bombbag;
11626 break;
11627
11628 case ssiCBYRNA:
11629 temp_sub->d1 = itype_cbyrna;
11630 break;
11631
11632 case ssiROCS:
11633 temp_sub->d1 = itype_rocs;
11634 break;
11635
11636 case ssiHOVERBOOTS:
11637 temp_sub->d1 = itype_hoverboots;
11638 break;
11639
11640 case ssiSPINSCROLL:
11641 temp_sub->d1 = itype_spinscroll;
11642 break;
11643
11644 case ssiCROSSSCROLL:
11645 temp_sub->d1 = itype_crossscroll;
11646 break;
11647
11648 case ssiQUAKESCROLL:
11649 temp_sub->d1 = itype_quakescroll;
11650 break;
11651
11652 case ssiWHISPRING:
11653 temp_sub->d1 = itype_whispring;
11654 break;
11655
11656 case ssiCHARGERING:
11657 temp_sub->d1 = itype_chargering;
11658 break;
11659
11660 case ssiPERILSCROLL:
11661 temp_sub->d1 = itype_perilscroll;
11662 break;
11663
11664 case ssiWEALTHMEDAL:
11665 temp_sub->d1 = itype_wealthmedal;
11666 break;
11667
11668 case ssiHEARTRING:
11669 temp_sub->d1 = itype_heartring;
11670 break;
11671
11672 case ssiMAGICRING:
11673 temp_sub->d1 = itype_magicring;
11674 break;
11675
11676 case ssiSPINSCROLL2:
11677 temp_sub->d1 = itype_spinscroll2;
11678 break;
11679
11680 case ssiQUAKESCROLL2:
11681 temp_sub->d1 = itype_quakescroll2;
11682 break;
11683
11684 case ssiAGONY:
11685 temp_sub->d1 = itype_agony;
11686 break;
11687
11688 case ssiSTOMPBOOTS:
11689 temp_sub->d1 = itype_stompboots;
11690 break;
11691
11692 case ssiWHIMSICALRING:
11693 temp_sub->d1 = itype_whimsicalring;
11694 break;
11695
11696 case ssiPERILRING:
11697 temp_sub->d1 = itype_perilring;
11698 break;
11699
11700 default:
11701 temp_sub->d1 += itype_custom1 - ssiMAX;
11702 }
11703 }
11704
11705 //fall-through
11706 default:
11707
1/2
✓ Branch 0 taken 39640 times.
✗ Branch 1 not taken.
39640 if(!p_getc(&(temp_sub->dp1),f))
11708 return qe_invalid;
11709
11710 39640 break;
11711 }
11712
11713
2/2
✓ Branch 0 taken 9237 times.
✓ Branch 1 taken 33869 times.
43106 if(s_version < 7)
11714 {
11715
3/3
✓ Branch 0 taken 27879 times.
✓ Branch 1 taken 1366 times.
✓ Branch 2 taken 4624 times.
33869 switch(temp_sub->type)
11716 {
11717 case ssoMAGICGAUGE:
11718 {
11719
2/2
✓ Branch 0 taken 118 times.
✓ Branch 1 taken 1248 times.
1366 if(!temp_sub->d9)
11720 1248 temp_sub->d9 = -1; //-1 now represents 'always'
11721 1366 break;
11722 }
11723 case ssoLIFEGAUGE:
11724 4624 temp_sub->d9 = 0; //Unused, doesn't do anything? Clear it...
11725 4624 break;
11726 }
11727 33869 }
11728
11729
3/3
✓ Branch 0 taken 3250 times.
✓ Branch 1 taken 38354 times.
✓ Branch 2 taken 1502 times.
43106 switch(temp_sub->type)
11730 {
11731 case ssoTEXT:
11732 case ssoTEXTBOX:
11733 case ssoCURRENTITEMTEXT:
11734 case ssoCURRENTITEMCLASSTEXT:
11735
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3250 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3250 if(g->objects[j].dp1 != NULL) delete[](char *)g->objects[j].dp1;
11736
11737 3250 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11738 3250 g->objects[j].dp1 = new char[temp_size+2];
11739 3250 strcpy((char*)g->objects[j].dp1,tempdp1);
11740 3250 break;
11741
11742 case ssoCOUNTER:
11743
1/2
✓ Branch 0 taken 1502 times.
✗ Branch 1 not taken.
1502 if(s_version<3)
11744 {
11745 temp_sub->d6=(temp_sub->d6?1:0)+(temp_sub->d8?2:0);
11746 temp_sub->d8=0;
11747 }
11748
11749 default:
11750 39856 memcpy(&g->objects[j],temp_sub,sizeof(subscreen_object));
11751 39856 break;
11752 }
11753
11754 43106 g->name[0] = '\0';
11755 43106 strncat(g->name, tempname, 64 - 1);
11756 43106 g->ss_type = temp_ss;
11757 43106 }
11758
11759
2/2
✓ Branch 0 taken 6739870 times.
✓ Branch 1 taken 26496 times.
6766366 for(j=numsub; j<MAXSUBSCREENITEMS; j++)
11760 {
11761 //clear all unused object in this subscreen -DD
11762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6739870 times.
6739870 switch(g->objects[j].type)
11763 {
11764 case ssoTEXT:
11765 case ssoTEXTBOX:
11766 case ssoCURRENTITEMTEXT:
11767 case ssoCURRENTITEMCLASSTEXT:
11768 if(g->objects[j].dp1 != NULL) delete [](char *)g->objects[j].dp1;
11769
11770 //fall through
11771 default:
11772 6739870 memset(&g->objects[j],0,sizeof(subscreen_object));
11773 6739870 break;
11774 }
11775 6739870 }
11776
11777 26496 return 0;
11778 26496 }
11779
11780 612 int32_t readsubscreens(PACKFILE *f)
11781 {
11782 word s_version, s_cversion;
11783 dword dummy;
11784
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(!p_igetw(&s_version,f))
11785 return qe_invalid;
11786 612 FFCore.quest_format[vSubscreen] = s_version;
11787
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&s_cversion,f))
11788 return qe_invalid;
11789
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetl(&dummy,f)) //section size
11790 return qe_invalid;
11791
11792
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 405 times.
612 if(s_version < 8)
11793 207 return read_old_subscreens(f,s_version);
11794
11795 405 subscreens_active.clear();
11796 405 subscreens_passive.clear();
11797 405 subscreens_overlay.clear();
11798
11799 byte sz;
11800
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&sz,f))
11801 return qe_invalid;
11802
2/2
✓ Branch 0 taken 777 times.
✓ Branch 1 taken 405 times.
1182 for(byte q = 0; q < sz; ++q)
11803 {
11804 777 ZCSubscreen& tmp = subscreens_active.emplace_back();
11805
1/2
✓ Branch 0 taken 777 times.
✗ Branch 1 not taken.
777 if (auto ret = tmp.read(f, s_version))
11806 return ret;
11807 777 }
11808
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&sz,f))
11809 return qe_invalid;
11810
2/2
✓ Branch 0 taken 1584 times.
✓ Branch 1 taken 405 times.
1989 for(byte q = 0; q < sz; ++q)
11811 {
11812 1584 ZCSubscreen& tmp = subscreens_passive.emplace_back();
11813
1/2
✓ Branch 0 taken 1584 times.
✗ Branch 1 not taken.
1584 if (auto ret = tmp.read(f, s_version))
11814 return ret;
11815 1584 }
11816
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_getc(&sz,f))
11817 return qe_invalid;
11818
2/2
✓ Branch 0 taken 552 times.
✓ Branch 1 taken 405 times.
957 for(byte q = 0; q < sz; ++q)
11819 {
11820 552 ZCSubscreen& tmp = subscreens_overlay.emplace_back();
11821
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 552 times.
552 if (auto ret = tmp.read(f, s_version))
11822 return ret;
11823 552 }
11824 405 return 0;
11825 612 }
11826
11827 void reset_subscreen(subscreen_group *tempss)
11828 {
11829 for(int32_t i=0; i<MAXSUBSCREENITEMS; ++i)
11830 {
11831 switch(tempss->objects[i].type)
11832 {
11833 case ssoTEXT:
11834 case ssoTEXTBOX:
11835 case ssoCURRENTITEMTEXT:
11836 case ssoCURRENTITEMCLASSTEXT:
11837 if(tempss->objects[i].dp1 != NULL) delete [](char *)tempss->objects[i].dp1;
11838
11839 //fall through
11840 default:
11841 memset(&tempss->objects[i],0,sizeof(subscreen_object));
11842 break;
11843 }
11844 }
11845 }
11846
11847 107 void reset_subscreens()
11848 {
11849 107 subscreens_active.clear();
11850 107 subscreens_passive.clear();
11851 107 subscreens_overlay.clear();
11852 107 }
11853
11854 107 int32_t setupsubscreens()
11855 {
11856 107 reset_subscreens();
11857 //return 0;
11858
2/2
✓ Branch 0 taken 107 times.
✓ Branch 1 taken 214 times.
321 for(int q = 0; q < 2; ++q)
11859 {
11860 214 subscreens_active.emplace_back();
11861 214 subscreens_passive.emplace_back();
11862 214 }
11863 107 int32_t tempsubscreen=subscr_mode;
11864
11865
1/2
✓ Branch 0 taken 107 times.
✗ Branch 1 not taken.
107 if(tempsubscreen>=ssdtMAX)
11866 tempsubscreen=0;
11867
11868
1/3
✗ Branch 0 not taken.
✓ Branch 1 taken 107 times.
✗ Branch 2 not taken.
107 switch(tempsubscreen)
11869 {
11870 case ssdtOLD:
11871 case ssdtNEWSUBSCR:
11872 case ssdtREV2:
11873 case ssdtBSZELDA:
11874 case ssdtBSZELDAMODIFIED:
11875 case ssdtBSZELDAENHANCED:
11876 case ssdtBSZELDACOMPLETE:
11877 {
11878 107 subscreens_active[0].load_old(default_subscreen_active[tempsubscreen][0]);
11879 107 subscreens_active[0].sub_type=sstACTIVE;
11880 107 subscreens_active[0].name = "Active Subscreen (Triforce)";
11881 107 subscreens_active[1].load_old(default_subscreen_active[tempsubscreen][1]);
11882 107 subscreens_active[1].sub_type=sstACTIVE;
11883 107 subscreens_active[1].name = "Active Subscreen (Dungeon Map)";
11884 107 subscreens_passive[0].load_old(default_subscreen_passive[tempsubscreen][0]);
11885 107 subscreens_passive[0].sub_type=sstPASSIVE;
11886 107 subscreens_passive[0].name = "Passive Subscreen (Magic)";
11887 107 subscreens_passive[1].load_old(default_subscreen_passive[tempsubscreen][1]);
11888 107 subscreens_passive[1].sub_type=sstPASSIVE;
11889 107 subscreens_passive[1].name = "Passive Subscreen (No Magic)";
11890 107 break;
11891 }
11892
11893 case ssdtZ3:
11894 {
11895 subscreens_active[0].load_old(z3_active_a);
11896 subscreens_active[0].sub_type=sstACTIVE;
11897 subscreens_active[1].load_old(z3_active_ab);
11898 subscreens_active[1].sub_type=sstACTIVE;
11899 subscreens_passive[0].load_old(z3_passive_a);
11900 subscreens_passive[0].sub_type=sstPASSIVE;
11901 subscreens_passive[1].load_old(z3_passive_ab);
11902 subscreens_passive[1].sub_type=sstPASSIVE;
11903 break;
11904 }
11905 }
11906 107 subscr_mode = ssdtMAX;
11907 107 return 0;
11908 }
11909
11910 extern std::vector<std::shared_ptr<zasm_script>> zasm_scripts;
11911
11912 extern script_data *ffscripts[NUMSCRIPTFFC];
11913 extern script_data *itemscripts[NUMSCRIPTITEM];
11914 extern script_data *guyscripts[NUMSCRIPTGUYS];
11915 extern script_data *lwpnscripts[NUMSCRIPTWEAPONS];
11916 extern script_data *ewpnscripts[NUMSCRIPTWEAPONS];
11917 extern script_data *globalscripts[NUMSCRIPTGLOBAL];
11918 extern script_data *genericscripts[NUMSCRIPTSGENERIC];
11919 extern script_data *playerscripts[NUMSCRIPTPLAYER];
11920 extern script_data *screenscripts[NUMSCRIPTSCREEN];
11921 extern script_data *dmapscripts[NUMSCRIPTSDMAP];
11922 extern script_data *itemspritescripts[NUMSCRIPTSITEMSPRITE];
11923 extern script_data *comboscripts[NUMSCRIPTSCOMBODATA];
11924 extern script_data *subscreenscripts[NUMSCRIPTSSUBSCREEN];
11925
11926 static std::vector<const script_data*> read_scripts;
11927
11928 1086 int32_t readffscript(PACKFILE *f, zquestheader *Header)
11929 {
11930 int32_t dummy;
11931 1086 word s_version=0, s_cversion=0, zmeta_version=0;
11932 1086 byte numscripts=0;
11933 1086 numscripts=numscripts; //to avoid unused variables warnings
11934 int32_t ret;
11935 1086 read_scripts.clear();
11936 1086 zasm_scripts.clear();
11937
11938 //section version info
11939
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1086 times.
1086 if(!p_igetw(&s_version,f))
11940 {
11941 return qe_invalid;
11942 }
11943
11944 1086 FFCore.quest_format[vFFScript] = s_version;
11945
11946
1/2
✓ Branch 0 taken 1086 times.
✗ Branch 1 not taken.
1086 if(!p_igetw(&s_cversion,f))
11947 {
11948 return qe_invalid;
11949 }
11950
11951
2/2
✓ Branch 0 taken 663 times.
✓ Branch 1 taken 423 times.
1086 if(s_version >= 18)
11952 {
11953
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetw(&zmeta_version,f))
11954 {
11955 return qe_invalid;
11956 }
11957 423 }
11958
11959 //section size
11960
1/2
✓ Branch 0 taken 1086 times.
✗ Branch 1 not taken.
1086 if(!p_igetl(&dummy,f))
11961 {
11962 return qe_invalid;
11963 }
11964
11965
2/2
✓ Branch 0 taken 879 times.
✓ Branch 1 taken 207 times.
1086 if ( FFCore.quest_format[vLastCompile] < 13 ) FFCore.quest_format[vLastCompile] = s_version;
11966 1086 al_trace("Loaded scripts last compiled in ZScript version: %d\n", (FFCore.quest_format[vLastCompile]));
11967
11968 //finally... section data
11969
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 1080 times.
314430 for(int32_t i = 0; i < ((s_version < 2) ? NUMSCRIPTFFCOLD : NUMSCRIPTFFC); i++)
11970 {
11971 313344 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ffscripts[i], zmeta_version);
11972
11973
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if (ret)
11974 {
11975 return qe_invalid;
11976 }
11977 313344 }
11978
11979 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
11980 * This fixes changes to sprite jump values introduced in early 2.55 alphas.
11981 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
11982 * there was a version bump a week before a change that broke stuff.
11983 */
11984
7/8
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 657 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
✓ Branch 4 taken 423 times.
✓ Branch 5 taken 423 times.
✓ Branch 6 taken 423 times.
✓ Branch 7 taken 423 times.
1080 if(((Header->zelda_version < 0x253)||((Header->zelda_version == 0x253)&&(Header->build<33))||((Header->zelda_version > 0x253) && s_version < 12)))
11985 {
11986 1503 set_qr(qr_SPRITE_JUMP_IS_TRUNCATED,1);
11987 1503 }
11988
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 189 times.
612 if(s_version < 19)
11989 {
11990 189 set_qr(qr_FLUCTUATING_ENEMY_JUMP,1);
11991 189 }
11992
11993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(s_version > 1)
11994 {
11995
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 612 times.
157284 for(int32_t i = 0; i < NUMSCRIPTITEM; i++)
11996 {
11997 156672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemscripts[i], zmeta_version);
11998
11999
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if (ret)
12000 {
12001 return qe_invalid;
12002 }
12003 156672 }
12004
12005
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 612 times.
157284 for(int32_t i = 0; i < NUMSCRIPTGUYS; i++)
12006 {
12007 156672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &guyscripts[i], zmeta_version);
12008
12009
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if (ret)
12010 {
12011 return qe_invalid;
12012 }
12013 156672 }
12014
12015
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 script_data *fake = new script_data(ScriptType::None, 0);
12016
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 612 times.
157284 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12017 {
12018 156672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &fake, zmeta_version);
12019
12020
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if (ret)
12021 {
12022 return qe_invalid;
12023 }
12024 156672 }
12025
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 delete fake;
12026
12027
2/2
✓ Branch 0 taken 156672 times.
✓ Branch 1 taken 612 times.
157284 for(int32_t i = 0; i < NUMSCRIPTSCREEN; i++)
12028 {
12029 156672 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &screenscripts[i], zmeta_version);
12030
12031
1/2
✓ Branch 0 taken 156672 times.
✗ Branch 1 not taken.
156672 if (ret)
12032 {
12033 return qe_invalid;
12034 }
12035 156672 }
12036
12037
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 189 times.
612 if(s_version > 16)
12038 {
12039
2/2
✓ Branch 0 taken 3384 times.
✓ Branch 1 taken 423 times.
3807 for(int32_t i = 0; i < NUMSCRIPTGLOBAL; ++i)
12040 {
12041 3384 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12042
12043
1/2
✓ Branch 0 taken 3384 times.
✗ Branch 1 not taken.
3384 if (ret)
12044 {
12045 return qe_invalid;
12046 }
12047 3384 }
12048 423 }
12049
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 else if(s_version > 13)
12050 {
12051 for(int32_t i = 0; i < NUMSCRIPTGLOBAL255OLD; ++i)
12052 {
12053 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12054
12055 if (ret)
12056 {
12057 return qe_invalid;
12058 }
12059 }
12060
12061 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12062 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12063
12064 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12065 }
12066
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 else if(s_version > 4)
12067 {
12068
2/2
✓ Branch 0 taken 756 times.
✓ Branch 1 taken 189 times.
945 for(int32_t i = 0; i < NUMSCRIPTGLOBAL253; ++i)
12069 {
12070 756 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12071
12072
1/2
✓ Branch 0 taken 756 times.
✗ Branch 1 not taken.
756 if (ret)
12073 {
12074 return qe_invalid;
12075 }
12076 756 }
12077
12078
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12079
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12080
12081
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12082
12083
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12084
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12085
12086
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12087
12088
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12089
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete globalscripts[GLOBAL_SCRIPT_F6];
12090
12091
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12092
12093
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12094
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12095
12096
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12097 189 }
12098 else
12099 {
12100 for(int32_t i = 0; i < NUMSCRIPTGLOBALOLD; i++)
12101 {
12102 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &globalscripts[i], zmeta_version);
12103
12104 if (ret)
12105 {
12106 return qe_invalid;
12107 }
12108 }
12109
12110 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12111 delete globalscripts[GLOBAL_SCRIPT_ONSAVELOAD];
12112
12113 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVELOAD);
12114
12115 if(globalscripts[GLOBAL_SCRIPT_ONLAUNCH] != NULL)
12116 delete globalscripts[GLOBAL_SCRIPT_ONLAUNCH];
12117
12118 globalscripts[GLOBAL_SCRIPT_ONLAUNCH] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONLAUNCH);
12119
12120 if(globalscripts[GLOBAL_SCRIPT_ONCONTGAME] != NULL)
12121 delete globalscripts[GLOBAL_SCRIPT_ONCONTGAME];
12122
12123 globalscripts[GLOBAL_SCRIPT_ONCONTGAME] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONCONTGAME);
12124
12125 if(globalscripts[GLOBAL_SCRIPT_F6] != NULL)
12126 delete globalscripts[GLOBAL_SCRIPT_F6];
12127
12128 globalscripts[GLOBAL_SCRIPT_F6] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_F6);
12129
12130 if(globalscripts[GLOBAL_SCRIPT_ONSAVE] != NULL)
12131 delete globalscripts[GLOBAL_SCRIPT_ONSAVE];
12132
12133 globalscripts[GLOBAL_SCRIPT_ONSAVE] = new script_data(ScriptType::Global, GLOBAL_SCRIPT_ONSAVE);
12134 }
12135
12136
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 189 times.
612 if(s_version > 10) //expanded the number of Player scripts to 5.
12137 {
12138
2/2
✓ Branch 0 taken 2115 times.
✓ Branch 1 taken 423 times.
2538 for(int32_t i = 0; i < NUMSCRIPTPLAYER; i++)
12139 {
12140 2115 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12141
12142
1/2
✓ Branch 0 taken 2115 times.
✗ Branch 1 not taken.
2115 if (ret)
12143 {
12144 return qe_invalid;
12145 }
12146 2115 }
12147 423 }
12148 else
12149 {
12150
2/2
✓ Branch 0 taken 567 times.
✓ Branch 1 taken 189 times.
756 for(int32_t i = 0; i < NUMSCRIPTHEROOLD; i++)
12151 {
12152 567 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &playerscripts[i], zmeta_version);
12153
12154
1/2
✓ Branch 0 taken 567 times.
✗ Branch 1 not taken.
567 if (ret)
12155 {
12156 return qe_invalid;
12157 }
12158 567 }
12159
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(playerscripts[3] != NULL)
12160
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 delete playerscripts[3];
12161
12162
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 playerscripts[3] = new script_data(ScriptType::Player, 3);
12163
12164
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(playerscripts[4] != NULL)
12165
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 189 times.
189 delete playerscripts[4];
12166
12167
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 playerscripts[4] = new script_data(ScriptType::Player, 4);
12168 }
12169
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 189 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
612 if(s_version > 8 && s_version < 10)
12170 {
12171
12172 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12173 {
12174 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12175
12176 if (ret)
12177 {
12178 return qe_invalid;
12179 }
12180 }
12181 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12182 {
12183 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12184
12185 if (ret)
12186 {
12187 return qe_invalid;
12188 }
12189 }
12190
12191 }
12192
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if(s_version >= 10)
12193 {
12194
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 423 times.
108711 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12195 {
12196 108288 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &lwpnscripts[i], zmeta_version);
12197
12198
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if (ret)
12199 {
12200 return qe_invalid;
12201 }
12202 108288 }
12203
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 423 times.
108711 for(int32_t i = 0; i < NUMSCRIPTWEAPONS; i++)
12204 {
12205 108288 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &ewpnscripts[i], zmeta_version);
12206
12207
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if (ret)
12208 {
12209 return qe_invalid;
12210 }
12211 108288 }
12212
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 423 times.
108711 for(int32_t i = 0; i < NUMSCRIPTSDMAP; i++)
12213 {
12214 108288 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &dmapscripts[i], zmeta_version);
12215
12216
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if (ret)
12217 {
12218 return qe_invalid;
12219 }
12220 108288 }
12221
12222 423 }
12223
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if(s_version >=12)
12224 {
12225
2/2
✓ Branch 0 taken 108288 times.
✓ Branch 1 taken 423 times.
108711 for(int32_t i = 0; i < NUMSCRIPTSITEMSPRITE; i++)
12226 {
12227 108288 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &itemspritescripts[i], zmeta_version);
12228
12229
1/2
✓ Branch 0 taken 108288 times.
✗ Branch 1 not taken.
108288 if (ret)
12230 {
12231 return qe_invalid;
12232 }
12233 108288 }
12234 423 }
12235
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if(s_version >=15)
12236 {
12237
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 423 times.
216999 for(int32_t i = 0; i < NUMSCRIPTSCOMBODATA; i++)
12238 {
12239 216576 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &comboscripts[i], zmeta_version);
12240
12241
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if (ret)
12242 {
12243 return qe_invalid;
12244 }
12245 216576 }
12246 423 }
12247
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if(s_version >19)
12248 {
12249 423 word numgenscripts = NUMSCRIPTSGENERIC;
12250
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetw(&numgenscripts,f))
12251 {
12252 return qe_invalid;
12253 }
12254
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 423 times.
216999 for(int32_t i = 0; i < numgenscripts; i++)
12255 {
12256 216576 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &genericscripts[i], zmeta_version);
12257
12258
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if (ret)
12259 {
12260 return qe_invalid;
12261 }
12262 216576 }
12263 423 }
12264
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 405 times.
612 if(s_version >21)
12265 {
12266 405 word numsubscripts = NUMSCRIPTSSUBSCREEN;
12267
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&numsubscripts,f))
12268 {
12269 return qe_invalid;
12270 }
12271
2/2
✓ Branch 0 taken 103680 times.
✓ Branch 1 taken 405 times.
104085 for(int32_t i = 0; i < numsubscripts; i++)
12272 {
12273 103680 ret = read_one_ffscript(f, Header, i, s_version, s_cversion, &subscreenscripts[i], zmeta_version);
12274
12275
1/2
✓ Branch 0 taken 103680 times.
✗ Branch 1 not taken.
103680 if (ret)
12276 {
12277 return qe_invalid;
12278 }
12279 103680 }
12280 405 }
12281 612 }
12282
12283
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(s_version > 2)
12284 {
12285 int32_t bufsize;
12286 612 p_igetl(&bufsize, f);
12287
2/4
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
612 if (bufsize < 0 || bufsize > 1024*1024*10)
12288 {
12289 // God help anyone storing more than 10MB of code in the script buffer.
12290 return qe_invalid;
12291 }
12292 612 char * buf = new char[bufsize+1];
12293 612 pfread(buf, bufsize, f);
12294 612 buf[bufsize]=0;
12295
12296
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 zScript = string(buf);
12297
12298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 delete[] buf;
12299 word numffcbindings;
12300 612 p_igetw(&numffcbindings, f);
12301
12302
2/2
✓ Branch 0 taken 9662 times.
✓ Branch 1 taken 612 times.
10274 for(int32_t i=0; i<numffcbindings; i++)
12303 {
12304 word id;
12305 9662 p_igetw(&id, f);
12306 9662 p_igetl(&bufsize, f);
12307
2/4
✓ Branch 0 taken 9662 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 9662 times.
9662 if (bufsize < 0 || bufsize > 1024)
12308 return qe_invalid;
12309 9662 buf = new char[bufsize+1];
12310 9662 pfread(buf, bufsize, f);
12311 9662 buf[bufsize]=0;
12312
12313 //fix for buggy older saved quests -DD
12314
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9662 times.
9662 if(id < NUMSCRIPTFFC-1)
12315 9662 ffcmap[id].scriptname = buf;
12316
12317
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 9662 times.
9662 delete[] buf;
12318 9662 }
12319
12320 word numglobalbindings;
12321 612 p_igetw(&numglobalbindings, f);
12322
12323
2/2
✓ Branch 0 taken 1758 times.
✓ Branch 1 taken 612 times.
2370 for(int32_t i=0; i<numglobalbindings; i++)
12324 {
12325 word id;
12326 1758 p_igetw(&id, f);
12327 1758 p_igetl(&bufsize, f);
12328
2/4
✓ Branch 0 taken 1758 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1758 times.
✗ Branch 3 not taken.
1758 if (bufsize < 0 || bufsize > 1024)
12329 return qe_invalid;
12330 1758 buf = new char[bufsize+1];
12331 1758 pfread(buf, bufsize, f);
12332 1758 buf[bufsize]=0;
12333
12334 // id in principle should be valid, since slot assignment cannot assign a global script to a bogus slot.
12335 // However, because of a corruption bug, some 2.50.x quests contain bogus entries in the global bindings table.
12336 // Ignore these. -DD
12337
2/2
✓ Branch 0 taken 540 times.
✓ Branch 1 taken 1218 times.
1758 if (id < NUMSCRIPTGLOBAL)
12338 {
12339 //Disable old '~Continue's, they'd wreak havoc. Bit messy, apologies ~Joe
12340
1/2
✓ Branch 0 taken 1218 times.
✗ Branch 1 not taken.
1218 if(strcmp(buf,"~Continue") == 0)
12341 {
12342 globalmap[id].scriptname = "";
12343
12344 if(globalscripts[GLOBAL_SCRIPT_ONSAVELOAD] != NULL)
12345 globalscripts[GLOBAL_SCRIPT_ONSAVELOAD]->disable();
12346 }
12347 else
12348 {
12349 1218 globalmap[id].scriptname = buf;
12350 }
12351 1218 }
12352
12353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1758 times.
1758 delete[] buf;
12354 1758 }
12355
12356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(s_version > 3)
12357 {
12358 word numitembindings;
12359 612 p_igetw(&numitembindings, f);
12360
12361
2/2
✓ Branch 0 taken 1152 times.
✓ Branch 1 taken 612 times.
1764 for(int32_t i=0; i<numitembindings; i++)
12362 {
12363 word id;
12364 1152 p_igetw(&id, f);
12365 1152 p_igetl(&bufsize, f);
12366
2/4
✓ Branch 0 taken 1152 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1152 times.
1152 if (bufsize < 0 || bufsize > 1024)
12367 return qe_invalid;
12368 1152 buf = new char[bufsize+1];
12369 1152 pfread(buf, bufsize, f);
12370 1152 buf[bufsize]=0;
12371
12372 //fix this too
12373
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
1152 if(id <NUMSCRIPTITEM-1)
12374 1152 itemmap[id].scriptname = buf;
12375
12376
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1152 times.
1152 delete[] buf;
12377 1152 }
12378 612 }
12379 //(v9+)
12380
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if(s_version > 8)
12381 {
12382 //npc scripts
12383 word numnpcbindings;
12384 423 p_igetw(&numnpcbindings, f);
12385
12386
2/2
✓ Branch 0 taken 31 times.
✓ Branch 1 taken 423 times.
454 for(int32_t i=0; i<numnpcbindings; i++)
12387 {
12388 word id;
12389 31 p_igetw(&id, f);
12390 31 p_igetl(&bufsize, f);
12391
2/4
✓ Branch 0 taken 31 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 31 times.
✗ Branch 3 not taken.
31 if (bufsize < 0 || bufsize > 1024)
12392 return qe_invalid;
12393 31 buf = new char[bufsize+1];
12394 31 pfread(buf, bufsize, f);
12395 31 buf[bufsize]=0;
12396
12397 //fix this too
12398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 if(id <NUMSCRIPTGUYS-1)
12399 31 npcmap[id].scriptname = buf;
12400
12401
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 31 times.
31 delete[] buf;
12402 31 }
12403 //lweapon
12404 word numlwpnbindings;
12405 423 p_igetw(&numlwpnbindings, f);
12406
12407
2/2
✓ Branch 0 taken 213 times.
✓ Branch 1 taken 423 times.
636 for(int32_t i=0; i<numlwpnbindings; i++)
12408 {
12409 word id;
12410 213 p_igetw(&id, f);
12411 213 p_igetl(&bufsize, f);
12412
2/4
✓ Branch 0 taken 213 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 213 times.
✗ Branch 3 not taken.
213 if (bufsize < 0 || bufsize > 1024)
12413 return qe_invalid;
12414 213 buf = new char[bufsize+1];
12415 213 pfread(buf, bufsize, f);
12416 213 buf[bufsize]=0;
12417
12418 //fix this too
12419
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 213 times.
213 if(id <NUMSCRIPTWEAPONS-1)
12420 213 lwpnmap[id].scriptname = buf;
12421
12422
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 213 times.
213 delete[] buf;
12423 213 }
12424 //eweapon
12425 word numewpnbindings;
12426 423 p_igetw(&numewpnbindings, f);
12427
12428
2/2
✓ Branch 0 taken 280 times.
✓ Branch 1 taken 423 times.
703 for(int32_t i=0; i<numewpnbindings; i++)
12429 {
12430 word id;
12431 280 p_igetw(&id, f);
12432 280 p_igetl(&bufsize, f);
12433
2/4
✓ Branch 0 taken 280 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 280 times.
✗ Branch 3 not taken.
280 if (bufsize < 0 || bufsize > 1024)
12434 return qe_invalid;
12435 280 buf = new char[bufsize+1];
12436 280 pfread(buf, bufsize, f);
12437 280 buf[bufsize]=0;
12438
12439 //fix this too
12440
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 if(id <NUMSCRIPTWEAPONS-1)
12441 280 ewpnmap[id].scriptname = buf;
12442
12443
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 280 times.
280 delete[] buf;
12444 280 }
12445 //hero
12446 word numherobindings;
12447 423 p_igetw(&numherobindings, f);
12448
12449
2/2
✓ Branch 0 taken 21 times.
✓ Branch 1 taken 423 times.
444 for(int32_t i=0; i<numherobindings; i++)
12450 {
12451 word id;
12452 21 p_igetw(&id, f);
12453 21 p_igetl(&bufsize, f);
12454
2/4
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 21 times.
21 if (bufsize < 0 || bufsize > 1024)
12455 return qe_invalid;
12456 21 buf = new char[bufsize+1];
12457 21 pfread(buf, bufsize, f);
12458 21 buf[bufsize]=0;
12459
12460 //fix this too
12461
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 21 times.
21 if(id <NUMSCRIPTPLAYER-1)
12462 21 playermap[id].scriptname = buf;
12463
12464
1/2
✓ Branch 0 taken 21 times.
✗ Branch 1 not taken.
21 delete[] buf;
12465 21 }
12466 //dmaps
12467 word numdmapbindings;
12468 423 p_igetw(&numdmapbindings, f);
12469
12470
2/2
✓ Branch 0 taken 255 times.
✓ Branch 1 taken 423 times.
678 for(int32_t i=0; i<numdmapbindings; i++)
12471 {
12472 word id;
12473 255 p_igetw(&id, f);
12474 255 p_igetl(&bufsize, f);
12475
2/4
✓ Branch 0 taken 255 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 255 times.
✗ Branch 3 not taken.
255 if (bufsize < 0 || bufsize > 1024)
12476 return qe_invalid;
12477 255 buf = new char[bufsize+1];
12478 255 pfread(buf, bufsize, f);
12479 255 buf[bufsize]=0;
12480
12481 //fix this too
12482
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 if(id <NUMSCRIPTSDMAP-1)
12483 255 dmapmap[id].scriptname = buf;
12484
12485
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 255 times.
255 delete[] buf;
12486 255 }
12487 //screen
12488 word numscreenbindings;
12489 423 p_igetw(&numscreenbindings, f);
12490
12491
2/2
✓ Branch 0 taken 333 times.
✓ Branch 1 taken 423 times.
756 for(int32_t i=0; i<numscreenbindings; i++)
12492 {
12493 word id;
12494 333 p_igetw(&id, f);
12495 333 p_igetl(&bufsize, f);
12496
2/4
✓ Branch 0 taken 333 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 333 times.
✗ Branch 3 not taken.
333 if (bufsize < 0 || bufsize > 1024)
12497 return qe_invalid;
12498 333 buf = new char[bufsize+1];
12499 333 pfread(buf, bufsize, f);
12500 333 buf[bufsize]=0;
12501
12502 //fix this too
12503
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 if(id <NUMSCRIPTSDMAP-1)
12504 333 screenmap[id].scriptname = buf;
12505
12506
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 333 times.
333 delete[] buf;
12507 333 }
12508 423 }
12509
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if(s_version > 11)
12510 {
12511 word numspritebindings;
12512 423 p_igetw(&numspritebindings, f);
12513
12514
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 423 times.
467 for(int32_t i=0; i<numspritebindings; i++)
12515 {
12516 word id;
12517 44 p_igetw(&id, f);
12518 44 p_igetl(&bufsize, f);
12519
2/4
✓ Branch 0 taken 44 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 44 times.
✗ Branch 3 not taken.
44 if (bufsize < 0 || bufsize > 1024)
12520 return qe_invalid;
12521 44 buf = new char[bufsize+1];
12522 44 pfread(buf, bufsize, f);
12523 44 buf[bufsize]=0;
12524
12525 //fix this too
12526
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 if(id <NUMSCRIPTSDMAP-1)
12527 44 itemspritemap[id].scriptname = buf;
12528
12529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44 times.
44 delete[] buf;
12530 44 }
12531 423 }
12532
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if(s_version >= 15)
12533 {
12534 word numcombobindings;
12535 423 p_igetw(&numcombobindings, f);
12536
12537
2/2
✓ Branch 0 taken 143 times.
✓ Branch 1 taken 423 times.
566 for(int32_t i=0; i<numcombobindings; i++)
12538 {
12539 word id;
12540 143 p_igetw(&id, f);
12541 143 p_igetl(&bufsize, f);
12542
2/4
✓ Branch 0 taken 143 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 143 times.
143 if (bufsize < 0 || bufsize > 1024)
12543 return qe_invalid;
12544 143 buf = new char[bufsize+1];
12545 143 pfread(buf, bufsize, f);
12546 143 buf[bufsize]=0;
12547
12548 //fix this too
12549
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 if(id <NUMSCRIPTSCOMBODATA-1)
12550 143 comboscriptmap[id].scriptname = buf;
12551
12552
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 143 times.
143 delete[] buf;
12553 143 }
12554 423 }
12555
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if(s_version > 19)
12556 {
12557 word numgenericbindings;
12558 423 p_igetw(&numgenericbindings, f);
12559
12560
2/2
✓ Branch 0 taken 103 times.
✓ Branch 1 taken 423 times.
526 for(int32_t i=0; i<numgenericbindings; i++)
12561 {
12562 word id;
12563 103 p_igetw(&id, f);
12564 103 p_igetl(&bufsize, f);
12565
2/4
✓ Branch 0 taken 103 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 103 times.
103 if (bufsize < 0 || bufsize > 1024)
12566 return qe_invalid;
12567 103 buf = new char[bufsize+1];
12568 103 pfread(buf, bufsize, f);
12569 103 buf[bufsize]=0;
12570
12571 //fix this too
12572
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 if(id <NUMSCRIPTSGENERIC-1)
12573 103 genericmap[id].scriptname = buf;
12574
12575
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 103 times.
103 delete[] buf;
12576 103 }
12577 423 }
12578
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 405 times.
612 if(s_version > 21)
12579 {
12580 word numsubscreenbindings;
12581 405 p_igetw(&numsubscreenbindings, f);
12582
12583
2/2
✓ Branch 0 taken 7 times.
✓ Branch 1 taken 405 times.
412 for(int32_t i=0; i<numsubscreenbindings; i++)
12584 {
12585 word id;
12586 7 p_igetw(&id, f);
12587 7 p_igetl(&bufsize, f);
12588
2/4
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 7 times.
7 if (bufsize < 0 || bufsize > 1024)
12589 return qe_invalid;
12590 7 buf = new char[bufsize+1];
12591 7 pfread(buf, bufsize, f);
12592 7 buf[bufsize]=0;
12593
12594 //fix this too
12595
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 if(id <NUMSCRIPTSSUBSCREEN-1)
12596 7 subscreenmap[id].scriptname = buf;
12597
12598
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7 times.
7 delete[] buf;
12599 7 }
12600 405 }
12601 612 }
12602
12603 // Set ZScriptVersion to the value encoded in the script's meta.ffscript_v.
12604 // This is only updated when the scripts have been recompiled.
12605 // They should all match each other.
12606 612 std::optional<word> zscript_version;
12607
2/2
✓ Branch 0 taken 189 times.
✓ Branch 1 taken 423 times.
612 if (s_version >= 16)
12608 {
12609
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 for (auto script : read_scripts)
12610 {
12611 if (script->meta.ffscript_v == 0 || script->meta.ffscript_v > s_version)
12612 break;
12613
12614 if (!zscript_version.has_value())
12615 {
12616 zscript_version = script->meta.ffscript_v;
12617 continue;
12618 }
12619
12620 if (zscript_version.value() != script->meta.ffscript_v)
12621 {
12622 zscript_version.reset();
12623 break;
12624 }
12625 }
12626
12627
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 423 times.
423 if (!zscript_version.has_value())
12628 423 al_trace("WARNING: Setting zscript version to section version as fallback.\n");
12629 423 }
12630 612 setZScriptVersion(zscript_version.value_or(s_version));
12631 612 read_scripts.clear();
12632
12633 612 return 0;
12634 612 }
12635
12636 694 void reset_scripts()
12637 {
12638 #ifdef IS_PLAYER
12639 // We can't modify the script data while jit threads are possibly compiling them.
12640 void jit_shutdown();
12641 685 jit_shutdown();
12642 #endif
12643
12644
2/2
✓ Branch 0 taken 355328 times.
✓ Branch 1 taken 694 times.
356022 for(int32_t i=0; i<NUMSCRIPTSGENERIC; i++)
12645 {
12646
1/2
✓ Branch 0 taken 355328 times.
✗ Branch 1 not taken.
355328 if (genericscripts[i]!=NULL) genericscripts[i]->disable();
12647 else genericscripts[i] = new script_data({ScriptType::Generic, i});
12648 355328 }
12649
12650
2/2
✓ Branch 0 taken 355328 times.
✓ Branch 1 taken 694 times.
356022 for(int32_t i=0; i<NUMSCRIPTFFC; i++)
12651 {
12652
1/2
✓ Branch 0 taken 355328 times.
✗ Branch 1 not taken.
355328 if (ffscripts[i])
12653 355328 ffscripts[i]->disable();
12654 else
12655 ffscripts[i] = new script_data(ScriptType::FFC, i);
12656 355328 }
12657
12658
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<NUMSCRIPTITEM; i++)
12659 {
12660
1/2
✓ Branch 0 taken 177664 times.
✗ Branch 1 not taken.
177664 if (itemscripts[i])
12661 177664 itemscripts[i]->disable();
12662 else
12663 itemscripts[i] = new script_data(ScriptType::Item, i);
12664 177664 }
12665
12666
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<NUMSCRIPTGUYS; i++)
12667 {
12668
1/2
✓ Branch 0 taken 177664 times.
✗ Branch 1 not taken.
177664 if (guyscripts[i])
12669 177664 guyscripts[i]->disable();
12670 else
12671 guyscripts[i] = new script_data(ScriptType::NPC, i);
12672 177664 }
12673
12674
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<NUMSCRIPTSCREEN; i++)
12675 {
12676
1/2
✓ Branch 0 taken 177664 times.
✗ Branch 1 not taken.
177664 if (screenscripts[i])
12677 177664 screenscripts[i]->disable();
12678 else
12679 screenscripts[i] = new script_data(ScriptType::Screen, i);
12680 177664 }
12681
12682
2/2
✓ Branch 0 taken 5552 times.
✓ Branch 1 taken 694 times.
6246 for(int32_t i=0; i<NUMSCRIPTGLOBAL; i++)
12683 {
12684
1/2
✓ Branch 0 taken 5552 times.
✗ Branch 1 not taken.
5552 if (globalscripts[i])
12685 5552 globalscripts[i]->disable();
12686 else
12687 globalscripts[i] = new script_data(ScriptType::Global, i);
12688 5552 }
12689
12690
2/2
✓ Branch 0 taken 3470 times.
✓ Branch 1 taken 694 times.
4164 for(int32_t i=0; i<NUMSCRIPTPLAYER; i++)
12691 {
12692
1/2
✓ Branch 0 taken 3470 times.
✗ Branch 1 not taken.
3470 if (playerscripts[i])
12693 3470 playerscripts[i]->disable();
12694 else
12695 playerscripts[i] = new script_data(ScriptType::Player, i);
12696 3470 }
12697
12698
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12699 {
12700
1/2
✓ Branch 0 taken 177664 times.
✗ Branch 1 not taken.
177664 if (lwpnscripts[i])
12701 177664 lwpnscripts[i]->disable();
12702 else
12703 lwpnscripts[i] = new script_data(ScriptType::Lwpn, i);
12704 177664 }
12705
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<NUMSCRIPTWEAPONS; i++)
12706 {
12707
1/2
✓ Branch 0 taken 177664 times.
✗ Branch 1 not taken.
177664 if (ewpnscripts[i])
12708 177664 ewpnscripts[i]->disable();
12709 else
12710 ewpnscripts[i] = new script_data(ScriptType::Ewpn, i);
12711 177664 }
12712
12713
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<NUMSCRIPTSDMAP; i++)
12714 {
12715
1/2
✓ Branch 0 taken 177664 times.
✗ Branch 1 not taken.
177664 if (dmapscripts[i])
12716 177664 dmapscripts[i]->disable();
12717 else
12718 dmapscripts[i] = new script_data(ScriptType::DMap, i);
12719 177664 }
12720
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE; i++)
12721 {
12722
1/2
✓ Branch 0 taken 177664 times.
✗ Branch 1 not taken.
177664 if (itemspritescripts[i])
12723 177664 itemspritescripts[i]->disable();
12724 else
12725 itemspritescripts[i] = new script_data(ScriptType::ItemSprite, i);
12726 177664 }
12727
2/2
✓ Branch 0 taken 355328 times.
✓ Branch 1 taken 694 times.
356022 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA; i++)
12728 {
12729
1/2
✓ Branch 0 taken 355328 times.
✗ Branch 1 not taken.
355328 if (comboscripts[i])
12730 355328 comboscripts[i]->disable();
12731 else
12732 comboscripts[i] = new script_data(ScriptType::Combo, i);
12733 355328 }
12734
2/2
✓ Branch 0 taken 177664 times.
✓ Branch 1 taken 694 times.
178358 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN; i++)
12735 {
12736
1/2
✓ Branch 0 taken 177664 times.
✗ Branch 1 not taken.
177664 if (subscreenscripts[i])
12737 177664 subscreenscripts[i]->disable();
12738 else
12739 subscreenscripts[i] = new script_data(ScriptType::EngineSubscreen, i);
12740 177664 }
12741 694 }
12742
12743 1916838 int32_t read_one_ffscript(PACKFILE *f, zquestheader *, int32_t script_index, word s_version, word , script_data **script, word zmeta_version)
12744 {
12745 // TODO: refactor to just take a script_data*
12746 ASSERT(*script);
12747
12748 //Please also update loadquest() when modifying this method -DD
12749 1916838 char b33[34] = {0};
12750 1916838 b33[33] = 0;
12751 1916838 int32_t num_commands=1000;
12752
12753
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1916838 times.
1916838 if(s_version>=2)
12754 {
12755
1/2
✓ Branch 0 taken 1916838 times.
✗ Branch 1 not taken.
1916838 if(!p_igetl(&num_commands,f))
12756 {
12757 return qe_invalid;
12758 }
12759 1916838 }
12760
12761 #ifdef ZC_FUZZ
12762 const int32_t command_limit = 300000;
12763 #else
12764 1916838 const int32_t command_limit = 10000000;
12765 #endif
12766
2/4
✓ Branch 0 taken 1916838 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 1916838 times.
1916838 if (num_commands < 0 || num_commands > command_limit)
12767 {
12768 return qe_invalid;
12769 }
12770
12771 1916838 std::vector<ffscript> zasm;
12772
1/2
✓ Branch 0 taken 1916838 times.
✗ Branch 1 not taken.
1916838 zasm.reserve(num_commands);
12773
12774
2/2
✓ Branch 0 taken 1625211 times.
✓ Branch 1 taken 291627 times.
1916838 if(s_version >= 16)
12775 {
12776
1/2
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
1625211 zasm_meta temp_meta;
12777
12778
2/4
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625211 times.
✗ Branch 3 not taken.
1625211 if(!p_igetw(&(temp_meta.zasm_v),f))
12779 {
12780 return qe_invalid;
12781 }
12782
12783
2/4
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625211 times.
✗ Branch 3 not taken.
1625211 if(!p_igetw(&(temp_meta.meta_v),f))
12784 {
12785 return qe_invalid;
12786 }
12787
12788
2/4
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625211 times.
✗ Branch 3 not taken.
1625211 if(!p_igetw(&(temp_meta.ffscript_v),f))
12789 {
12790 return qe_invalid;
12791 }
12792
12793
2/4
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625211 times.
✗ Branch 3 not taken.
1625211 if(!p_getc(&(temp_meta.script_type),f))
12794 {
12795 return qe_invalid;
12796 }
12797
12798
2/2
✓ Branch 0 taken 13001688 times.
✓ Branch 1 taken 1625211 times.
14626899 for(int32_t q = 0; q < 8; ++q)
12799 {
12800
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 12857808 times.
13001688 if(zmeta_version < 3)
12801 {
12802
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 4748040 times.
4891920 for(int32_t c = 0; c < 33; ++c)
12803 {
12804
2/4
✓ Branch 0 taken 4748040 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4748040 times.
✗ Branch 3 not taken.
4748040 if(!p_getc(&(b33[c]),f))
12805 {
12806 return qe_invalid;
12807 }
12808 4748040 }
12809
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.run_idens[q].assign(b33);
12810 143880 }
12811 else
12812 {
12813
2/4
✓ Branch 0 taken 12857808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12857808 times.
✗ Branch 3 not taken.
12857808 if(!p_getcstr(&temp_meta.run_idens[q],f))
12814 {
12815 return qe_invalid;
12816 }
12817 }
12818 13001688 }
12819
12820
2/2
✓ Branch 0 taken 1625211 times.
✓ Branch 1 taken 13001688 times.
14626899 for(int32_t q = 0; q < 8; ++q)
12821 {
12822
2/4
✓ Branch 0 taken 13001688 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 13001688 times.
✗ Branch 3 not taken.
13001688 if(!p_getc(&(temp_meta.run_types[q]),f))
12823 {
12824 return qe_invalid;
12825 }
12826 13001688 }
12827
12828
2/4
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625211 times.
✗ Branch 3 not taken.
1625211 if(!p_getc(&(temp_meta.flags),f))
12829 {
12830 return qe_invalid;
12831 }
12832
12833
2/4
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625211 times.
✗ Branch 3 not taken.
1625211 if(!p_igetw(&(temp_meta.compiler_v1),f))
12834 {
12835 return qe_invalid;
12836 }
12837
12838
2/4
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625211 times.
✗ Branch 3 not taken.
1625211 if(!p_igetw(&(temp_meta.compiler_v2),f))
12839 {
12840 return qe_invalid;
12841 }
12842
12843
2/4
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625211 times.
✗ Branch 3 not taken.
1625211 if(!p_igetw(&(temp_meta.compiler_v3),f))
12844 {
12845 return qe_invalid;
12846 }
12847
12848
2/4
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1625211 times.
✗ Branch 3 not taken.
1625211 if(!p_igetw(&(temp_meta.compiler_v4),f))
12849 {
12850 return qe_invalid;
12851 }
12852
12853
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 1607226 times.
1625211 if(zmeta_version == 2)
12854 {
12855
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
12856 {
12857
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
12858 {
12859 return qe_invalid;
12860 }
12861 593505 }
12862
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.script_name.assign(b33);
12863
12864
2/2
✓ Branch 0 taken 17985 times.
✓ Branch 1 taken 593505 times.
611490 for(int32_t c = 0; c < 33; ++c)
12865 {
12866
2/4
✓ Branch 0 taken 593505 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 593505 times.
✗ Branch 3 not taken.
593505 if(!p_getc(&b33[c],f))
12867 {
12868 return qe_invalid;
12869 }
12870 593505 }
12871
1/2
✓ Branch 0 taken 17985 times.
✗ Branch 1 not taken.
17985 temp_meta.author.assign(b33);
12872 17985 }
12873
1/2
✓ Branch 0 taken 1607226 times.
✗ Branch 1 not taken.
1607226 else if(zmeta_version > 2)
12874 {
12875
2/4
✓ Branch 0 taken 1607226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1607226 times.
✗ Branch 3 not taken.
1607226 if(!p_getcstr(&temp_meta.script_name,f))
12876 return qe_invalid;
12877
2/4
✓ Branch 0 taken 1607226 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1607226 times.
✗ Branch 3 not taken.
1607226 if(!p_getcstr(&temp_meta.author,f))
12878 return qe_invalid;
12879 1607226 auto num_meta_attrib = (zmeta_version < 5 ? 4 : 10);
12880
2/2
✓ Branch 0 taken 16072260 times.
✓ Branch 1 taken 1607226 times.
17679486 for(auto q = 0; q < num_meta_attrib; ++q)
12881 {
12882
2/4
✓ Branch 0 taken 16072260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16072260 times.
✗ Branch 3 not taken.
16072260 if(!p_getcstr(&temp_meta.attributes[q],f))
12883 return qe_invalid;
12884
2/4
✓ Branch 0 taken 16072260 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 16072260 times.
✗ Branch 3 not taken.
16072260 if(!p_getwstr(&temp_meta.attributes_help[q],f))
12885 return qe_invalid;
12886 16072260 }
12887
2/2
✓ Branch 0 taken 12857808 times.
✓ Branch 1 taken 1607226 times.
14465034 for(auto q = 0; q < 8; ++q)
12888 {
12889
2/4
✓ Branch 0 taken 12857808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12857808 times.
✗ Branch 3 not taken.
12857808 if(!p_getcstr(&temp_meta.attribytes[q],f))
12890 return qe_invalid;
12891
2/4
✓ Branch 0 taken 12857808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12857808 times.
✗ Branch 3 not taken.
12857808 if(!p_getwstr(&temp_meta.attribytes_help[q],f))
12892 return qe_invalid;
12893 12857808 }
12894
2/2
✓ Branch 0 taken 12857808 times.
✓ Branch 1 taken 1607226 times.
14465034 for(auto q = 0; q < 8; ++q)
12895 {
12896
2/4
✓ Branch 0 taken 12857808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12857808 times.
✗ Branch 3 not taken.
12857808 if(!p_getcstr(&temp_meta.attrishorts[q],f))
12897 return qe_invalid;
12898
2/4
✓ Branch 0 taken 12857808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12857808 times.
✗ Branch 3 not taken.
12857808 if(!p_getwstr(&temp_meta.attrishorts_help[q],f))
12899 return qe_invalid;
12900 12857808 }
12901
2/2
✓ Branch 0 taken 25715616 times.
✓ Branch 1 taken 1607226 times.
27322842 for(auto q = 0; q < 16; ++q)
12902 {
12903
2/4
✓ Branch 0 taken 25715616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25715616 times.
✗ Branch 3 not taken.
25715616 if(!p_getcstr(&temp_meta.usrflags[q],f))
12904 return qe_invalid;
12905
2/4
✓ Branch 0 taken 25715616 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25715616 times.
✗ Branch 3 not taken.
25715616 if(!p_getwstr(&temp_meta.usrflags_help[q],f))
12906 return qe_invalid;
12907 25715616 }
12908 1607226 }
12909
2/2
✓ Branch 0 taken 1607226 times.
✓ Branch 1 taken 17985 times.
1625211 if(zmeta_version > 3)
12910 {
12911
2/2
✓ Branch 0 taken 12857808 times.
✓ Branch 1 taken 1607226 times.
14465034 for(auto q = 0; q < 8; ++q)
12912 {
12913
2/4
✓ Branch 0 taken 12857808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12857808 times.
✗ Branch 3 not taken.
12857808 if(!p_getcstr(&temp_meta.initd[q],f))
12914 return qe_invalid;
12915
2/4
✓ Branch 0 taken 12857808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12857808 times.
✗ Branch 3 not taken.
12857808 if(!p_getwstr(&temp_meta.initd_help[q],f))
12916 return qe_invalid;
12917 12857808 }
12918
2/2
✓ Branch 0 taken 12857808 times.
✓ Branch 1 taken 1607226 times.
14465034 for(auto q = 0; q < 8; ++q)
12919 {
12920
2/4
✓ Branch 0 taken 12857808 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12857808 times.
✗ Branch 3 not taken.
12857808 if(!p_getc(&temp_meta.initd_type[q],f))
12921 return qe_invalid;
12922 12857808 }
12923 1607226 }
12924 else
12925 {
12926
2/2
✓ Branch 0 taken 143880 times.
✓ Branch 1 taken 17985 times.
161865 for(auto q = 0; q < 8; ++q)
12927 {
12928
1/2
✓ Branch 0 taken 143880 times.
✗ Branch 1 not taken.
143880 temp_meta.initd[q] = temp_meta.run_idens[q];
12929 143880 }
12930 }
12931
12932
1/2
✓ Branch 0 taken 1625211 times.
✗ Branch 1 not taken.
1625211 (*script)->meta = temp_meta;
12933
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1625211 times.
1625211 }
12934
12935
2/2
✓ Branch 0 taken 94474566 times.
✓ Branch 1 taken 140726 times.
94615292 for(int32_t j=0; j<num_commands; j++)
12936 {
12937
1/2
✓ Branch 0 taken 94474566 times.
✗ Branch 1 not taken.
94474566 auto& sc = zasm.emplace_back();
12938
2/4
✓ Branch 0 taken 94474566 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 94474566 times.
✗ Branch 3 not taken.
94474566 if(!p_igetw(&sc.command,f))
12939 {
12940 return qe_invalid;
12941 }
12942
12943
2/2
✓ Branch 0 taken 92698454 times.
✓ Branch 1 taken 1776112 times.
94474566 if(sc.command == 0xFFFF)
12944 {
12945 1776112 break;
12946 }
12947
12948
2/4
✓ Branch 0 taken 92698454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92698454 times.
✗ Branch 3 not taken.
92698454 if(!p_igetl(&sc.arg1,f))
12949 {
12950 return qe_invalid;
12951 }
12952
12953
2/4
✓ Branch 0 taken 92698454 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 92698454 times.
✗ Branch 3 not taken.
92698454 if(!p_igetl(&sc.arg2,f))
12954 {
12955 return qe_invalid;
12956 }
12957
12958
2/2
✓ Branch 0 taken 2367887 times.
✓ Branch 1 taken 90330567 times.
92698454 if(s_version >= 24)
12959
2/4
✓ Branch 0 taken 2367887 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2367887 times.
✗ Branch 3 not taken.
2367887 if(!p_igetl(&sc.arg3,f))
12960 return qe_invalid;
12961
12962
2/2
✓ Branch 0 taken 8623620 times.
✓ Branch 1 taken 84074834 times.
92698454 if(s_version >= 21)
12963 {
12964 8623620 uint32_t sz = 0;
12965
2/4
✓ Branch 0 taken 8623620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8623620 times.
✗ Branch 3 not taken.
8623620 if(!p_igetl(&sz,f))
12966 {
12967 return qe_invalid;
12968 }
12969
2/2
✓ Branch 0 taken 34128 times.
✓ Branch 1 taken 8589492 times.
8623620 if(sz) //string found
12970 {
12971
1/2
✓ Branch 0 taken 34128 times.
✗ Branch 1 not taken.
34128 sc.strptr = new std::string();
12972 char dummy;
12973
2/2
✓ Branch 0 taken 1312895 times.
✓ Branch 1 taken 34128 times.
1347023 for(size_t q = 0; q < sz; ++q)
12974 {
12975
2/4
✓ Branch 0 taken 1312895 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1312895 times.
✗ Branch 3 not taken.
1312895 if(!p_getc(&dummy,f))
12976 {
12977 return qe_invalid;
12978 }
12979
1/2
✓ Branch 0 taken 1312895 times.
✗ Branch 1 not taken.
1312895 sc.strptr->push_back(dummy);
12980 1312895 }
12981 34128 }
12982
2/4
✓ Branch 0 taken 8623620 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 8623620 times.
✗ Branch 3 not taken.
8623620 if(!p_igetl(&sz,f))
12983 {
12984 return qe_invalid;
12985 }
12986
2/2
✓ Branch 0 taken 2253 times.
✓ Branch 1 taken 8621367 times.
8623620 if(sz) //vector found
12987 {
12988
1/2
✓ Branch 0 taken 2253 times.
✗ Branch 1 not taken.
2253 sc.vecptr = new std::vector<int32_t>();
12989 int32_t dummy;
12990
2/2
✓ Branch 0 taken 14912 times.
✓ Branch 1 taken 2253 times.
17165 for(size_t q = 0; q < sz; ++q)
12991 {
12992
2/4
✓ Branch 0 taken 14912 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14912 times.
✗ Branch 3 not taken.
14912 if(!p_igetl(&dummy,f))
12993 {
12994 return qe_invalid;
12995 }
12996
1/2
✓ Branch 0 taken 14912 times.
✗ Branch 1 not taken.
14912 sc.vecptr->push_back(dummy);
12997 14912 }
12998 2253 }
12999 8623620 }
13000 92698454 }
13001
13002 // If the first command is unknown, invalidate the whole thing.
13003 // Saw this for https://www.purezc.net/index.php?page=quests&id=411 hero script 0
13004
5/6
✓ Branch 0 taken 1776112 times.
✓ Branch 1 taken 140726 times.
✓ Branch 2 taken 1762887 times.
✓ Branch 3 taken 13225 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 1762887 times.
1916838 if (!zasm.empty() && zasm[0].command >= NUMCOMMANDS && zasm[0].command != 0xFFFF)
13005 {
13006 al_trace("Warning: found script with bad instruction, disabling script: %s %d\n", ScriptTypeToString((*script)->id.type), (*script)->id.index);
13007 zasm.clear();
13008 }
13009
13010 1916838 zasm_script_id id = zasm_scripts.size();
13011
3/6
✓ Branch 0 taken 1916838 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1916838 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1916838 times.
✗ Branch 5 not taken.
1916838 auto& zs = zasm_scripts.emplace_back(std::make_shared<zasm_script>(id, (*script)->name(), std::move(zasm)));
13012 1916838 (*script)->zasm_script = zs;
13013
13014 1916838 return 0;
13015 1916838 }
13016
13017 extern SAMPLE customsfxdata[WAV_COUNT];
13018 extern uint8_t customsfxflag[WAV_COUNT>>3];
13019 extern int32_t sfxdat;
13020 extern DATAFILE *sfxdata;
13021 const char *old_sfx_string[Z35] =
13022 {
13023 "Arrow", "Sword beam", "Bomb blast", "Boomerang", "Subscreen cursor",
13024 "Shield is hit", "Item chime", "Roar (Dodongo, Gohma)", "Shutter", "Enemy dies",
13025 "Enemy is hit", "Low hearts warning", "Fire", "Ganon's fanfare", "Boss is hit", "Hammer",
13026 "Hookshot", "Message", "Player is hit", "Item fanfare", "Bomb placed", "Item pickup",
13027 "Refill", "Roar (Aquamentus, Gleeok, Ganon)", "Item pickup 2", "Ocean ambience",
13028 "Secret chime", "Player dies", "Stairs", "Sword", "Roar (Manhandla, Digdogger, Patra)",
13029 "Wand magic", "Whistle", "Zelda's fanfare", "Charging weapon", "Charging weapon 2",
13030 "Divine Fire", "Enemy falls from ceiling", "Divine Escape", "Fireball", "Tall Grass slashed",
13031 "Pound pounded", "Hover Boots", "Ice magic", "Jump", "Lens of Truth off", "Lens of Truth on",
13032 "Divine Protection shield", "Divine Protection 2", "Push block", "Rock", "Spell rocket down",
13033 "Spell rocket up", "Sword spin attack", "Splash", "Summon magic", "Sword tapping",
13034 "Sword tapping (secret)", "Whistle whirlwind", "Cane of Byrna orbit"
13035 };
13036 char *sfx_string[WAV_COUNT];
13037
13038 612 int32_t readsfx(PACKFILE *f, zquestheader *Header)
13039 {
13040 //these are here to bypass compiler warnings about unused arguments
13041 612 Header=Header;
13042
13043 int32_t dummy;
13044 612 word s_version=0, s_cversion=0;
13045 //int32_t ret;
13046 612 SAMPLE temp_sample = {};
13047 612 temp_sample.loop_start=0;
13048 612 temp_sample.loop_end=0;
13049 612 temp_sample.param=0;
13050
13051 //section version info
13052
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(!p_igetw(&s_version,f))
13053 {
13054 return qe_invalid;
13055 }
13056
13057 612 FFCore.quest_format[vSFX] = s_version;
13058
13059
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&s_cversion,f))
13060 {
13061 return qe_invalid;
13062 }
13063
13064 //section size
13065
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetl(&dummy,f))
13066 {
13067 return qe_invalid;
13068 }
13069
13070 /* HIGHLY UNORTHODOX UPDATING THING, by L
13071 * This fixes quests made before revision 411 (such as the 'Lost Isle Build'),
13072 * where the meaning of GOTOLESS changed. It also coincided with V_SFX
13073 * changing from 1 to 2.
13074 */
13075
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(s_version < 2)
13076 set_qr(qr_GOTOLESSNOTEQUAL,1);
13077
13078 /* End highly unorthodox updating thing */
13079
13080 612 int32_t wavcount = WAV_COUNT;
13081
13082
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(s_version < 6)
13083 wavcount = 128;
13084
13085 uint8_t tempflag[WAV_COUNT>>3];
13086
13087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(s_version < 4)
13088 {
13089 memset(tempflag, 0xFF, WAV_COUNT>>3);
13090 }
13091 else
13092 {
13093
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(s_version < 6)
13094 memset(tempflag, 0, WAV_COUNT>>3);
13095
13096
2/2
✓ Branch 0 taken 19584 times.
✓ Branch 1 taken 612 times.
20196 for(int32_t i=0; i<(wavcount>>3); i++)
13097 {
13098 19584 p_getc(&tempflag[i], f);
13099 19584 }
13100
13101 }
13102
13103
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(s_version>4)
13104 {
13105
2/2
✓ Branch 0 taken 156060 times.
✓ Branch 1 taken 612 times.
156672 for(int32_t i=1; i<WAV_COUNT; i++)
13106 {
13107 156060 sprintf(sfx_string[i],"s%03d",i);
13108
13109
2/2
✓ Branch 0 taken 119340 times.
✓ Branch 1 taken 36720 times.
156060 if((i<Z35))
13110 36720 strcpy(sfx_string[i], old_sfx_string[i-1]);
13111
13112
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 156060 times.
156060 if(i>=wavcount)
13113 continue;
13114
2/2
✓ Branch 0 taken 36003 times.
✓ Branch 1 taken 120057 times.
156060 if(get_bit(tempflag, i-1))
13115 {
13116 char tempname[36];
13117
13118
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(!pfread(tempname, 36, f))
13119 {
13120 return qe_invalid;
13121 }
13122
13123 36003 sfx_string[i][0] = '\0';
13124 36003 strncat(sfx_string[i], tempname, 36 - 1);
13125 36003 }
13126 else
13127 {
13128 120057 sprintf(sfx_string[i],"s%03d",i);
13129
13130
2/2
✓ Branch 0 taken 110897 times.
✓ Branch 1 taken 9160 times.
120057 if(i<Z35)
13131 9160 strcpy(sfx_string[i], old_sfx_string[i-1]);
13132 120057 sfx_string[i][35] = 0; //Force NULL Termination
13133 }
13134 156060 }
13135 612 }
13136 else
13137 {
13138 for(int32_t i=1; i<WAV_COUNT; i++)
13139 {
13140 sprintf(sfx_string[i],"s%03d",i);
13141
13142 if(i<Z35)
13143 strcpy(sfx_string[i], old_sfx_string[i-1]);
13144 }
13145 }
13146
13147 //finally... section data
13148
2/2
✓ Branch 0 taken 156060 times.
✓ Branch 1 taken 612 times.
156672 for(int32_t i=1; i<wavcount; i++)
13149 {
13150
2/2
✓ Branch 0 taken 36003 times.
✓ Branch 1 taken 120057 times.
156060 if(get_bit(tempflag, i-1))
13151 {
13152
13153
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(!p_igetl(&dummy,f))
13154 {
13155 return qe_invalid;
13156 }
13157
13158 36003 (temp_sample.bits) = dummy;
13159
13160
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(!p_igetl(&dummy,f))
13161 {
13162 return qe_invalid;
13163 }
13164
13165 36003 (temp_sample.stereo) = dummy;
13166
13167
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(!p_igetl(&dummy,f))
13168 {
13169 return qe_invalid;
13170 }
13171
13172 36003 (temp_sample.freq) = dummy;
13173
13174
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(!p_igetl(&dummy,f))
13175 {
13176 return qe_invalid;
13177 }
13178
13179 36003 (temp_sample.priority) = dummy;
13180
13181
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(!p_igetl(&(temp_sample.len),f))
13182 {
13183 return qe_invalid;
13184 }
13185
13186
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(!p_igetl(&(temp_sample.loop_start),f))
13187 {
13188 return qe_invalid;
13189 }
13190
13191
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(!p_igetl(&(temp_sample.loop_end),f))
13192 {
13193 return qe_invalid;
13194 }
13195
13196
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(!p_igetl(&(temp_sample.param),f))
13197 {
13198 return qe_invalid;
13199 }
13200
13201 36003 auto len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13202 #ifdef ZC_FUZZ
13203 const int32_t sfx_limit = 100000;
13204 if (len < 0 || len > sfx_limit)
13205 {
13206 return qe_invalid;
13207 }
13208 #endif
13209 36003 temp_sample.data = calloc(len,1);
13210
13211
1/2
✓ Branch 0 taken 36003 times.
✗ Branch 1 not taken.
36003 if(s_version < 3)
13212 len = (temp_sample.bits==8?1:2)*temp_sample.len;
13213
13214 //old-style, non-portable loading (Bad Allegro! Bad!!) -DD
13215
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 36003 times.
36003 if(s_version < 2)
13216 {
13217 if(!pfread(temp_sample.data, len,f))
13218 {
13219 return qe_invalid;
13220 }
13221 }
13222 else
13223 {
13224 //re-endianfy the data
13225 36003 int32_t wordstoread = len / sizeof(word);
13226
13227
2/2
✓ Branch 0 taken 981297181 times.
✓ Branch 1 taken 36003 times.
981333184 for(int32_t j=0; j<wordstoread; j++)
13228 {
13229 word temp;
13230
13231
1/2
✓ Branch 0 taken 981297181 times.
✗ Branch 1 not taken.
981297181 if(!p_igetw(&temp, f))
13232 {
13233 return qe_invalid;
13234 }
13235
13236 981297181 ((word *)temp_sample.data)[j] = temp;
13237 981297181 }
13238 }
13239 36003 }
13240
2/2
✓ Branch 0 taken 9160 times.
✓ Branch 1 taken 110897 times.
120057 else if(i < Z35)
13241 {
13242 9160 SAMPLE* datsamp = (SAMPLE*)(sfxdata[i].dat);
13243 9160 memcpy(&temp_sample, datsamp, sizeof(SAMPLE));
13244 9160 set_bit(tempflag, i-1, 1);
13245 9160 int32_t len = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13246 9160 temp_sample.data = calloc(len,1);
13247 9160 memcpy(temp_sample.data, datsamp->data, len);
13248 9160 }
13249 110897 else continue;
13250
13251
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45163 times.
45163 if(customsfxdata[i].data!=NULL)
13252 {
13253 // delete [] customsfxdata[i].data;
13254 45163 free(customsfxdata[i].data);
13255 45163 }
13256
13257 // customsfxdata[i].data = new byte[(temp_sample.bits==8?1:2)*temp_sample.len];
13258 45163 int32_t len2 = (temp_sample.bits==8?1:2)*(temp_sample.stereo==0?1:2)*temp_sample.len;
13259 45163 customsfxdata[i].data = calloc(len2,1);
13260 45163 customsfxdata[i].bits = temp_sample.bits;
13261 45163 customsfxdata[i].stereo = temp_sample.stereo;
13262 45163 customsfxdata[i].freq = temp_sample.freq;
13263 45163 customsfxdata[i].priority = temp_sample.priority;
13264 45163 customsfxdata[i].len = temp_sample.len;
13265 45163 customsfxdata[i].loop_start = temp_sample.loop_start;
13266 45163 customsfxdata[i].loop_end = temp_sample.loop_end;
13267 45163 customsfxdata[i].param = temp_sample.param;
13268 45163 int32_t cpylen = len2;
13269
13270
1/2
✓ Branch 0 taken 45163 times.
✗ Branch 1 not taken.
45163 if(s_version<3)
13271 {
13272 cpylen = (temp_sample.bits==8?1:2)*temp_sample.len;
13273 al_trace("WARNING: Quest SFX %d is in stereo, and may be corrupt.\n",i);
13274 }
13275
13276 45163 memcpy(customsfxdata[i].data,temp_sample.data,cpylen);
13277
13278 45163 free(temp_sample.data);
13279 45163 }
13280
13281 612 memcpy(customsfxflag, tempflag, WAV_COUNT>>3);
13282
13283 612 sfxdat=0;
13284 612 return 0;
13285 612 }
13286
13287 694 void setupsfx()
13288 {
13289
2/2
✓ Branch 0 taken 176970 times.
✓ Branch 1 taken 694 times.
177664 for(int32_t i=1; i<WAV_COUNT; i++)
13290 {
13291 176970 sprintf(sfx_string[i],"s%03d",i);
13292
13293
2/2
✓ Branch 0 taken 135330 times.
✓ Branch 1 taken 41640 times.
176970 if(i<Z35)
13294 {
13295 41640 strcpy(sfx_string[i], old_sfx_string[i-1]);
13296 41640 }
13297
13298 176970 memset(customsfxflag, 0, WAV_COUNT>>3);
13299
13300 176970 int32_t j=i;
13301
13302
2/2
✓ Branch 0 taken 42334 times.
✓ Branch 1 taken 134636 times.
176970 if(i>Z35)
13303 {
13304 134636 i=Z35;
13305 134636 }
13306
13307 176970 SAMPLE *temp_sample = (SAMPLE *)sfxdata[i].dat;
13308
13309
2/2
✓ Branch 0 taken 79815 times.
✓ Branch 1 taken 97155 times.
176970 if(customsfxdata[j].data!=NULL)
13310 {
13311 // delete [] customsfxdata[j].data;
13312 97155 free(customsfxdata[j].data);
13313 97155 }
13314
13315 // customsfxdata[j].data = new byte[(temp_sample->bits==8?1:2)*temp_sample->len];
13316 176970 customsfxdata[j].data = calloc((temp_sample->bits==8?1:2)*(temp_sample->stereo == 0 ? 1 : 2)*temp_sample->len,1);
13317 176970 customsfxdata[j].bits = temp_sample->bits;
13318 176970 customsfxdata[j].stereo = temp_sample->stereo;
13319 176970 customsfxdata[j].freq = temp_sample->freq;
13320 176970 customsfxdata[j].priority = temp_sample->priority;
13321 176970 customsfxdata[j].len = temp_sample->len;
13322 176970 customsfxdata[j].loop_start = temp_sample->loop_start;
13323 176970 customsfxdata[j].loop_end = temp_sample->loop_end;
13324 176970 customsfxdata[j].param = temp_sample->param;
13325 176970 memcpy(customsfxdata[j].data, (temp_sample->data), (temp_sample->bits==8?1:2)*(temp_sample->stereo==0 ? 1 : 2)*temp_sample->len);
13326 176970 i=j;
13327 176970 }
13328 694 }
13329
13330 extern char *guy_string[eMAXGUYS];
13331 extern const char *old_guy_string[OLDMAXGUYS];
13332
13333 694 int32_t readguys(PACKFILE *f, zquestheader *Header)
13334 {
13335
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 671 times.
694 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_guys);
13336
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
694 if (should_skip) return 0;
13337
13338 dword dummy;
13339 word guy_cversion;
13340 694 word guyversion=0;
13341
13342
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 671 times.
694 if(Header->zelda_version >= 0x193)
13343 {
13344 //section version info
13345
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&guyversion,f))
13346 {
13347 return qe_invalid;
13348 }
13349
13350 671 FFCore.quest_format[vGuys] = guyversion;
13351
13352
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&guy_cversion,f))
13353 {
13354 return qe_invalid;
13355 }
13356 671 al_trace("Guy CVersion is: %d\n", guy_cversion);
13357 //section size
13358
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&dummy,f))
13359 {
13360 return qe_invalid;
13361 }
13362 671 }
13363
13364
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(guyversion > 3)
13365 {
13366
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 612 times.
313956 for(int32_t i=0; i<MAXGUYS; i++)
13367 {
13368 char tempname[64];
13369
13370 // rev. 1511 : guyversion = 23. upped to 512 editable enemies. -Gleeok
13371 // if guyversion < 23 then there is only 256 enemies in the packfile, so default the rest.
13372
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 313344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
313344 if(guyversion < 23 && i >= OLDBETAMAXGUYS)
13373 {
13374 memset(tempname, 0, sizeof(char)*64);
13375 sprintf(tempname, "e%03d", i);
13376 strcpy(guy_string[i], tempname);
13377
13378 continue;
13379 }
13380
13381
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!pfread(tempname, 64, f))
13382 {
13383 return qe_invalid;
13384 }
13385
13386 // Don't retain names of uneditable enemy entries!
13387 // for version upgrade to 2.5
13388
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 313344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
313344 if(guyversion < 23 && i >= 177)
13389 {
13390 // some of the older builds have names such as 'zz123',
13391 // (this order gets messed up with some eXXX and some zzXXX)
13392 // so let's update to the newer naming convection. -Gleeok
13393 char tmpbuf[64];
13394 memset(tmpbuf, 0, sizeof(char)*64);
13395 sprintf(tmpbuf, "zz%03d", i);
13396
13397 if(memcmp(tempname, tmpbuf, size_t(5)) == 0)
13398 {
13399 memset(tempname, 0, sizeof(char)*64);
13400 sprintf(tempname, "e%03d", i);
13401 }
13402 }
13403
13404
6/6
✓ Branch 0 taken 108324 times.
✓ Branch 1 taken 205020 times.
✓ Branch 2 taken 102816 times.
✓ Branch 3 taken 5508 times.
✓ Branch 4 taken 93583 times.
✓ Branch 5 taken 9233 times.
313344 if(i >= OLDMAXGUYS || strlen(tempname)<1 || tempname[strlen(tempname)-1]!=' ')
13405 {
13406 304111 guy_string[i][0] = '\0';
13407 304111 strncat(guy_string[i], tempname, 64 - 1);
13408 304111 }
13409 else
13410 {
13411 9233 strcpy(guy_string[i],old_guy_string[i]);
13412 }
13413 313344 }
13414 612 }
13415 else
13416 {
13417
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 82 times.
42066 for(int32_t i=0; i<eMAXGUYS; i++)
13418 {
13419 41984 sprintf(guy_string[i],"zz%03d",i);
13420 41984 }
13421
13422
2/2
✓ Branch 0 taken 14514 times.
✓ Branch 1 taken 82 times.
14596 for(int32_t i=0; i<OLDMAXGUYS; i++)
13423 {
13424 14514 strcpy(guy_string[i],old_guy_string[i]);
13425 14514 }
13426 }
13427
13428
13429 //finally... section data
13430 694 init_guys(guyversion); //using default data for now...
13431
13432 // Goriya guy fix
13433
3/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
694 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<7)))
13434 {
13435
2/2
✓ Branch 0 taken 22 times.
✓ Branch 1 taken 60 times.
82 if(get_qr(qr_NEWENEMYTILES))
13436 {
13437 60 guysbuf[gGORIYA].tile=130;
13438 60 guysbuf[gGORIYA].e_tile=130;
13439 60 }
13440 82 }
13441
13442
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 23 times.
694 if(Header->zelda_version < 0x193)
13443 {
13444
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 5 times.
23 if(get_bit(deprecated_rules,46))
13445 {
13446 5 guysbuf[eDODONGO].cset=14;
13447 5 guysbuf[eDODONGO].bosspal=spDIG;
13448 5 }
13449 23 }
13450 // Not sure when this first changed, but it's necessary for 2.10, at least
13451 // @TODO: @BUG:1.92 - 1.84? Figure this out exactly for the final 2.50 release.
13452 //2.10 Fixes
13453
3/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
694 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<18)))
13454 {
13455 82 guysbuf[eWWIZ].editorflags |= ENEMY_FLAG5;
13456 82 guysbuf[eMOLDORM].editorflags |= ENEMY_FLAG6;
13457 82 guysbuf[eMANHAN].editorflags |= ENEMY_FLAG6;
13458 82 guysbuf[eCENT1].attributes[2] = 1;
13459 82 guysbuf[eCENT2].attributes[2] = 1;
13460 82 }
13461
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
694 if((Header->zelda_version <= 0x255) || (Header->zelda_version == 0x255 && Header->build < 47) )
13462 {
13463 694 guysbuf[eWPOLSV].defense[edefWhistle] = ed1HKO;
13464 694 }
13465
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if(Header->zelda_version <= 0x210)
13466 {
13467 82 guysbuf[eGLEEOK1F].attributes[5] = 16;
13468 82 guysbuf[eGLEEOK2F].attributes[5] = 16;
13469 82 guysbuf[eGLEEOK3F].attributes[5] = 16;
13470 82 guysbuf[eGLEEOK4F].attributes[5] = 16;
13471
13472 82 guysbuf[eWIZ1].attributes[3] = 1; //only set the enemy that needs backward compat, not all of them.
13473 82 guysbuf[eBATROBE].attributes[3] = 1;
13474 //guysbuf[eSUMMONER].misc4 = 1;
13475 82 guysbuf[eWWIZ].attributes[3] = 1;
13476 82 guysbuf[eDODONGO].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13477 82 guysbuf[eDODONGOBS].deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
13478 82 }
13479
2/2
✓ Branch 0 taken 682 times.
✓ Branch 1 taken 12 times.
694 if(Header->zelda_version == 0x190)
13480 {
13481 12 al_trace("Setting Tribble Properties for Version: %x", Header->zelda_version);
13482 12 guysbuf[eKEESETRIB].attributes[2] = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13483 12 guysbuf[eGELTRIB].attributes[2] = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13484 12 }
13485
13486 // The versions here may not be correct
13487 // zelda_version>=0x211 handled at guyversion<24
13488
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 676 times.
694 if(Header->zelda_version <= 0x190)
13489 {
13490 18 guysbuf[eCENT1].attributes[2] = 0;
13491 18 guysbuf[eCENT2].attributes[2] = 0;
13492 18 guysbuf[eMOLDORM].attributes[1] = 0;
13493 //guysbuf[eKEESETRIB].misc3 = eVIRE; //1.90 and earlier, keese and gel tribbles grew up into
13494 //guysbuf[eGELTRIB].misc3 = eZOL; //normal vires, and zols -Z (16th January, 2019 )
13495 18 }
13496
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 64 times.
676 else if(Header->zelda_version <= 0x210)
13497 {
13498 64 guysbuf[eCENT1].attributes[2] = 1;
13499 64 guysbuf[eCENT2].attributes[2] = 1;
13500 64 guysbuf[eMOLDORM].attributes[1] = 0;
13501 64 }
13502
13503
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 82 times.
694 if ( Header->zelda_version < 0x211 ) //Default rest rates for phantom ghinis, peahats and keese in < 2.50 quests
13504 {
13505 82 guysbuf[eKEESE1].attributes[15] = 120;
13506 82 guysbuf[eKEESE2].attributes[15] = 120;
13507 82 guysbuf[eKEESE3].attributes[15] = 120;
13508 82 guysbuf[eKEESETRIB].attributes[15] = 120;
13509 82 guysbuf[eKEESE1].attributes[16] = 16;
13510 82 guysbuf[eKEESE2].attributes[16] = 16;
13511 82 guysbuf[eKEESE3].attributes[16] = 16;
13512 82 guysbuf[eKEESETRIB].attributes[16] = 16;
13513
13514 82 guysbuf[ePEAHAT].attributes[15] = 80;
13515 82 guysbuf[ePEAHAT].attributes[16] = 16;
13516
13517 82 guysbuf[eGHINI2].attributes[15] = 120;
13518 82 guysbuf[eGHINI2].attributes[16] = 10;
13519
13520
2/2
✓ Branch 0 taken 16 times.
✓ Branch 1 taken 66 times.
82 if (replay_version_check(20))
13521 {
13522 66 guysbuf[eGHINI2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13523 66 guysbuf[eMOLDORM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13524 66 guysbuf[eKEESETRIB].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13525 66 guysbuf[eKEESE3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13526 66 guysbuf[eKEESE2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13527 66 guysbuf[eKEESE1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13528 66 guysbuf[eTEK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13529 66 guysbuf[eTEK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13530 66 guysbuf[ePEAHAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13531 66 guysbuf[eROCK].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13532 66 guysbuf[eTRAP].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13533 66 guysbuf[eWALLM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13534 66 guysbuf[ePOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13535 66 guysbuf[eMANHAN].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13536 66 guysbuf[eGLEEOK1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13537 66 guysbuf[eGLEEOK2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13538 66 guysbuf[eGLEEOK3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13539 66 guysbuf[eGLEEOK4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13540 66 guysbuf[eDIG1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13541 66 guysbuf[eDIG3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13542 66 guysbuf[eDIGPUP1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13543 66 guysbuf[eDIGPUP2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13544 66 guysbuf[eDIGPUP3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13545 66 guysbuf[eDIGPUP4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13546 66 guysbuf[eRAQUAM].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13547 66 guysbuf[eITEMFAIRY].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13548 66 guysbuf[eFIRE].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13549 66 guysbuf[eMANHAN2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13550 66 guysbuf[eTRAP_H].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13551 66 guysbuf[eTRAP_V].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13552 66 guysbuf[eTRAP_LR].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13553 66 guysbuf[eTRAP_UD].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13554 66 guysbuf[ePATRA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13555 66 guysbuf[ePATRA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13556 66 guysbuf[ePATRABS].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13557 66 guysbuf[eBAT].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13558 66 guysbuf[eGLEEOK1F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13559 66 guysbuf[eGLEEOK2F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13560 66 guysbuf[eGLEEOK3F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13561 66 guysbuf[eGLEEOK4F].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13562 66 guysbuf[eTRIGGER].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13563 66 guysbuf[ePATRAL2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13564 66 guysbuf[ePATRAL3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13565 66 guysbuf[eGOHMA1].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13566 66 guysbuf[eGOHMA2].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13567 66 guysbuf[eGOHMA3].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13568 66 guysbuf[eGOHMA4].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13569 66 guysbuf[eMPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13570 66 guysbuf[eWPOLSV].moveflags |= (move_can_waterwalk|move_can_pitwalk);
13571 66 }
13572 82 }
13573
13574
13575
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 612 times.
694 if(guyversion<=2)
13576 {
13577 82 return readherosprites2(f, guyversion==2?0:-1, 0);
13578 }
13579
13580
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(guyversion > 3)
13581 {
13582 guydata tempguy;
13583
13584
2/2
✓ Branch 0 taken 313344 times.
✓ Branch 1 taken 612 times.
313956 for(int32_t i=0; i<MAXGUYS; i++)
13585 {
13586
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 23) // May 2012 : 512 max enemies
13587 {
13588 if(i >= OLDBETAMAXGUYS)
13589 {
13590 memset(&guysbuf[i], 0, sizeof(guydata));
13591 continue;
13592 }
13593 }
13594
13595 313344 memset(&tempguy, 0, sizeof(guydata));
13596
13597 uint32_t flags1;
13598 uint32_t flags2;
13599
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetl(&(flags1),f))
13600 {
13601 return qe_invalid;
13602 }
13603
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetl(&(flags2),f))
13604 {
13605 return qe_invalid;
13606 }
13607 313344 tempguy.flags = guy_flags(flags1) | guy_flags(uint64_t(flags2)<<32ULL);
13608
13609
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if ( guyversion >= 36 ) //expanded tiles
13610 {
13611
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.tile),f))
13612 {
13613 return qe_invalid;
13614 }
13615 216576 }
13616 else
13617 {
13618
1/2
✓ Branch 0 taken 96768 times.
✗ Branch 1 not taken.
96768 if(!p_igetw(&(tempguy.tile),f))
13619 {
13620 return qe_invalid;
13621 }
13622 }
13623
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_getc(&(tempguy.width),f))
13624 {
13625 return qe_invalid;
13626 }
13627
13628
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_getc(&(tempguy.height),f))
13629 {
13630 return qe_invalid;
13631 }
13632
13633
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if ( guyversion >= 36 ) //expanded tiles
13634 {
13635
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.s_tile),f))
13636 {
13637 return qe_invalid;
13638 }
13639 216576 }
13640 else
13641 {
13642
1/2
✓ Branch 0 taken 96768 times.
✗ Branch 1 not taken.
96768 if(!p_igetw(&(tempguy.s_tile),f))
13643 {
13644 return qe_invalid;
13645 }
13646 }
13647
13648
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_getc(&(tempguy.s_width),f))
13649 {
13650 return qe_invalid;
13651 }
13652
13653
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_getc(&(tempguy.s_height),f))
13654 {
13655 return qe_invalid;
13656 }
13657
13658
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if ( guyversion >= 36 ) //expanded tiles
13659 {
13660
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.e_tile),f))
13661 {
13662 return qe_invalid;
13663 }
13664 216576 }
13665 else
13666 {
13667
1/2
✓ Branch 0 taken 96768 times.
✗ Branch 1 not taken.
96768 if(!p_igetw(&(tempguy.e_tile),f))
13668 {
13669 return qe_invalid;
13670 }
13671 }
13672
13673
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_getc(&(tempguy.e_width),f))
13674 {
13675 return qe_invalid;
13676 }
13677
13678
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_getc(&(tempguy.e_height),f))
13679 {
13680 return qe_invalid;
13681 }
13682
13683
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.hp),f))
13684 {
13685 return qe_invalid;
13686 }
13687
13688
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.family),f))
13689 {
13690 return qe_invalid;
13691 }
13692
13693
1/12
✗ Branch 0 not taken.
✓ Branch 1 taken 313344 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
313344 if(guyversion < 9 && (i==eDKNUT1 || i==eDKNUT2 || i==eDKNUT3 || i==eDKNUT4 || i==eDKNUT5)) // Whoops, forgot about Darknuts...
13694 {
13695 if(get_qr(qr_NEWENEMYTILES))
13696 {
13697 tempguy.s_tile=tempguy.e_tile+120;
13698 tempguy.s_width=tempguy.e_width;
13699 tempguy.s_height=tempguy.e_height;
13700 }
13701 else tempguy.s_tile=860;
13702 }
13703
13704
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.cset),f))
13705 {
13706 return qe_invalid;
13707 }
13708
13709
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.anim),f))
13710 {
13711 return qe_invalid;
13712 }
13713
13714
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.e_anim),f))
13715 {
13716 return qe_invalid;
13717 }
13718
13719
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.frate),f))
13720 {
13721 return qe_invalid;
13722 }
13723
13724
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.e_frate),f))
13725 {
13726 return qe_invalid;
13727 }
13728
13729
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 13) // April 2009
13730 {
13731 if(get_bit(deprecated_rules, qr_SLOWENEMYANIM_DEP))
13732 {
13733 tempguy.frate *= 2;
13734 tempguy.e_frate *= 2;
13735 }
13736 }
13737
13738
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 14) // May 1 2009
13739 {
13740 if(tempguy.anim==a2FRMSLOW)
13741 {
13742 tempguy.anim=a2FRM;
13743 tempguy.frate *= 2;
13744 }
13745
13746 if(tempguy.e_anim==a2FRMSLOW)
13747 {
13748 tempguy.e_anim=a2FRM;
13749 tempguy.e_frate *= 2;
13750 }
13751
13752 if(tempguy.anim==aFLIPSLOW)
13753 {
13754 tempguy.anim=aFLIP;
13755 tempguy.frate *= 2;
13756 }
13757
13758 if(tempguy.e_anim==aFLIPSLOW)
13759 {
13760 tempguy.e_anim=aFLIP;
13761 tempguy.e_frate *= 2;
13762 }
13763
13764 if(tempguy.anim == aNEWDWALK) tempguy.anim = a4FRM4DIR;
13765
13766 if(tempguy.e_anim == aNEWDWALK) tempguy.e_anim = a4FRM4DIR;
13767
13768 if(tempguy.anim == aNEWPOLV || tempguy.anim == a4FRM3TRAP)
13769 {
13770 tempguy.anim=a4FRM4DIR;
13771 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13772 }
13773
13774 if(tempguy.e_anim == aNEWPOLV || tempguy.e_anim == a4FRM3TRAP)
13775 {
13776 tempguy.e_anim=a4FRM4DIR;
13777 tempguy.s_tile=(get_qr(qr_NEWENEMYTILES) ? tempguy.e_tile : tempguy.tile)+20;
13778 }
13779 }
13780
13781
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.dp),f))
13782 {
13783 return qe_invalid;
13784 }
13785
13786 //correction for guy fire
13787
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 6)
13788 {
13789 if(i == gFIRE)
13790 tempguy.dp = 2;
13791 }
13792
13793
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.wdp),f))
13794 {
13795 return qe_invalid;
13796 }
13797
13798
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.weapon),f))
13799 {
13800 return qe_invalid;
13801 }
13802
13803 //correction for bosses using triple, "rising" fireballs
13804
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 5)
13805 {
13806 if(i == eLAQUAM || i == eRAQUAM || i == eGOHMA1 || i == eGOHMA2 ||
13807 i == eGOHMA3 || i == eGOHMA4)
13808 {
13809 if(tempguy.weapon == ewFireball)
13810 tempguy.weapon = ewFireball2;
13811 }
13812 }
13813
13814
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.rate),f))
13815 {
13816 return qe_invalid;
13817 }
13818
13819
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.hrate),f))
13820 {
13821 return qe_invalid;
13822 }
13823
13824
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.step),f))
13825 {
13826 return qe_invalid;
13827 }
13828
13829 // HIGHLY UNORTHODOX UPDATING THING, part 2
13830
3/4
✓ Branch 0 taken 2560 times.
✓ Branch 1 taken 310784 times.
✓ Branch 2 taken 2560 times.
✗ Branch 3 not taken.
313344 if(fixpolsvoice && tempguy.family==eePOLSV)
13831 {
13832 tempguy.step /= 2;
13833 }
13834
13835
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.homing),f))
13836 {
13837 return qe_invalid;
13838 }
13839
13840
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.grumble),f))
13841 {
13842 return qe_invalid;
13843 }
13844
13845
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.item_set),f))
13846 {
13847 return qe_invalid;
13848 }
13849
13850
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion>=22) // Version 22: Expand misc attributes to 32 bits
13851 {
13852
2/2
✓ Branch 0 taken 3133440 times.
✓ Branch 1 taken 313344 times.
3446784 for (int q = 0; q < 10; ++q)
13853 {
13854
1/2
✓ Branch 0 taken 3133440 times.
✗ Branch 1 not taken.
3133440 if (!p_igetl(&(tempguy.attributes[q]), f))
13855 {
13856 return qe_invalid;
13857 }
13858 3133440 }
13859 313344 }
13860 else
13861 {
13862 int16_t tempMisc;
13863
13864 for(int q=0;q<10;q++)
13865 {
13866 if (!p_igetw(&tempMisc, f))
13867 {
13868 return qe_invalid;
13869 }
13870 tempguy.attributes[q] = tempMisc;
13871 }
13872
13873 if(guyversion < 13) // April 2009 - a tiny Wizzrobe update
13874 {
13875 if(tempguy.family == eeWIZZ && !(tempguy.attributes[0]))
13876 tempguy.attributes[4] = 74;
13877 }
13878
13879 }
13880
13881
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.bgsfx),f))
13882 {
13883 return qe_invalid;
13884 }
13885
13886
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.bosspal),f))
13887 {
13888 return qe_invalid;
13889 }
13890
13891
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetw(&(tempguy.extend),f))
13892 {
13893 return qe_invalid;
13894 }
13895
13896 //! Enemy Defences
13897
13898 //If a 2.50 quest, use only the 2.5 defences.
13899
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 313344 times.
313344 if(guyversion >= 16 ) // November 2009 - Super Enemy Editor
13900 {
13901
2/2
✓ Branch 0 taken 5953536 times.
✓ Branch 1 taken 313344 times.
6266880 for(int32_t j=0; j<edefLAST; j++)
13902 {
13903
1/2
✓ Branch 0 taken 5953536 times.
✗ Branch 1 not taken.
5953536 if(!p_getc(&(tempguy.defense[j]),f))
13904 {
13905 return qe_invalid;
13906 }
13907 5953536 }
13908 //then copy the generic script defence to all the new script defences
13909
13910 313344 }
13911
13912
13913
13914
13915
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 313344 times.
313344 if(guyversion >= 18)
13916 {
13917
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_getc(&(tempguy.hitsfx),f))
13918 {
13919 return qe_invalid;
13920 }
13921
13922
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_getc(&(tempguy.deadsfx),f))
13923 {
13924 return qe_invalid;
13925 }
13926 313344 }
13927
13928
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion >= 22)
13929 {
13930
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetl(&(tempguy.attributes[10]), f))
13931 {
13932 return qe_invalid;
13933 }
13934
13935
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(!p_igetl(&(tempguy.attributes[11]),f))
13936 {
13937 return qe_invalid;
13938 }
13939 313344 }
13940 else if(guyversion >= 19)
13941 {
13942 int16_t tempMisc;
13943
13944 if(!p_igetw(&tempMisc,f))
13945 {
13946 return qe_invalid;
13947 }
13948
13949 tempguy.attributes[10] = tempMisc;
13950
13951 if(!p_igetw(&tempMisc,f))
13952 {
13953 return qe_invalid;
13954 }
13955
13956 tempguy.attributes[11] = tempMisc;
13957 }
13958
13959 //If a 2.54 or later quest, use all of the defences.
13960
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if(guyversion > 24) // Add new guyversion conditional statement
13961 {
13962
2/2
✓ Branch 0 taken 4764672 times.
✓ Branch 1 taken 216576 times.
4981248 for(int32_t j=edefLAST; j<edefLAST255; j++)
13963 {
13964
1/2
✓ Branch 0 taken 4764672 times.
✗ Branch 1 not taken.
4764672 if(!p_getc(&(tempguy.defense[j]),f))
13965 {
13966 return qe_invalid;
13967 }
13968 4764672 }
13969 216576 }
13970
13971
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion <= 24) // Port over generic script settings from old quests in the new editor.
13972 {
13973
2/2
✓ Branch 0 taken 967680 times.
✓ Branch 1 taken 96768 times.
1064448 for(int32_t j=edefSCRIPT01; j<=edefSCRIPT10; j++)
13974 {
13975 967680 tempguy.defense[j] = tempguy.defense[edefSCRIPT] ;
13976 967680 }
13977 96768 }
13978
13979 //tilewidth, tileheight, hitwidth, hitheight, hitzheight, hitxofs, hityofs, hitzofs
13980
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if(guyversion > 25)
13981 {
13982
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.txsz),f))
13983 {
13984 return qe_invalid;
13985 }
13986
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.tysz),f))
13987 {
13988 return qe_invalid;
13989 }
13990
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.hxsz),f))
13991 {
13992 return qe_invalid;
13993 }
13994
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.hysz),f))
13995 {
13996 return qe_invalid;
13997 }
13998
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.hzsz),f))
13999 {
14000 return qe_invalid;
14001 }
14002 /* Is it safe to read a fixed with getl, or do I need to typecast it? -Z
14003
14004 */
14005 216576 }
14006 //More Enemy Editor vars for 2.60
14007
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if(guyversion > 26)
14008 {
14009
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.hxofs),f))
14010 {
14011 return qe_invalid;
14012 }
14013
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.hyofs),f))
14014 {
14015 return qe_invalid;
14016 }
14017
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.xofs),f))
14018 {
14019 return qe_invalid;
14020 }
14021
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.yofs),f))
14022 {
14023 return qe_invalid;
14024 }
14025
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.zofs),f))
14026 {
14027 return qe_invalid;
14028 }
14029 216576 }
14030
14031
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion <= 27) // Port over generic script settings from old quests in the new editor.
14032 {
14033 96768 tempguy.wpnsprite = 0;
14034 96768 }
14035
14036
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if(guyversion > 27)
14037 {
14038
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.wpnsprite),f))
14039 {
14040 return qe_invalid;
14041 }
14042 216576 }
14043
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion <= 28) // Port over generic script settings from old quests in the new editor.
14044 {
14045 96768 tempguy.SIZEflags = 0;
14046 96768 }
14047
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if(guyversion > 28)
14048 {
14049
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.SIZEflags),f))
14050 {
14051 return qe_invalid;
14052 }
14053
14054 216576 }
14055
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion < 30) // Port over generic script settings from old quests in the new editor.
14056 {
14057 96768 tempguy.frozentile = 0;
14058 96768 tempguy.frozencset = 0;
14059 96768 tempguy.frozenclock = 0;
14060
2/2
✓ Branch 0 taken 967680 times.
✓ Branch 1 taken 96768 times.
1064448 for ( int32_t q = 0; q < 10; q++ ) tempguy.frozenmisc[q] = 0;
14061 96768 }
14062
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if(guyversion >= 30)
14063 {
14064
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.frozentile),f))
14065 {
14066 return qe_invalid;
14067 }
14068
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.frozencset),f))
14069 {
14070 return qe_invalid;
14071 }
14072
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.frozenclock),f))
14073 {
14074 return qe_invalid;
14075 }
14076
2/2
✓ Branch 0 taken 2165760 times.
✓ Branch 1 taken 216576 times.
2382336 for ( int32_t q = 0; q < 10; q++ ) {
14077
1/2
✓ Branch 0 taken 2165760 times.
✗ Branch 1 not taken.
2165760 if(!p_igetw(&(tempguy.frozenmisc[q]),f))
14078 {
14079 return qe_invalid;
14080 }
14081 2165760 }
14082
14083 216576 }
14084
14085
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if(guyversion >= 34)
14086 {
14087
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetw(&(tempguy.firesfx),f))
14088 {
14089 return qe_invalid;
14090 }
14091
2/2
✓ Branch 0 taken 3681792 times.
✓ Branch 1 taken 216576 times.
3898368 for(int q=15;q<32;++q)
14092 {
14093
1/2
✓ Branch 0 taken 3681792 times.
✗ Branch 1 not taken.
3681792 if(!p_igetl(&(tempguy.attributes[q]),f))
14094 {
14095 return qe_invalid;
14096 }
14097 3681792 }
14098
14099
2/2
✓ Branch 0 taken 6930432 times.
✓ Branch 1 taken 216576 times.
7147008 for ( int32_t q = 0; q < 32; q++ ) {
14100
1/2
✓ Branch 0 taken 6930432 times.
✗ Branch 1 not taken.
6930432 if(!p_igetl(&(tempguy.movement[q]),f))
14101 {
14102 return qe_invalid;
14103 }
14104 6930432 }
14105
2/2
✓ Branch 0 taken 6930432 times.
✓ Branch 1 taken 216576 times.
7147008 for ( int32_t q = 0; q < 32; q++ ) {
14106
1/2
✓ Branch 0 taken 6930432 times.
✗ Branch 1 not taken.
6930432 if(!p_igetl(&(tempguy.new_weapon[q]),f))
14107 {
14108 return qe_invalid;
14109 }
14110 6930432 }
14111
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetw(&(tempguy.script),f))
14112 {
14113 return qe_invalid;
14114 }
14115
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 216576 times.
1949184 for ( int32_t q = 0; q < 8; q++ )
14116 {
14117
1/2
✓ Branch 0 taken 1732608 times.
✗ Branch 1 not taken.
1732608 if(!p_igetl(&(tempguy.initD[q]),f))
14118 {
14119 return qe_invalid;
14120 }
14121 1732608 }
14122
2/2
✓ Branch 0 taken 433152 times.
✓ Branch 1 taken 216576 times.
649728 for ( int32_t q = 0; q < 2; q++ )
14123 {
14124
1/2
✓ Branch 0 taken 433152 times.
✗ Branch 1 not taken.
433152 if(!p_igetl(&(tempguy.initA[q]),f))
14125 {
14126 return qe_invalid;
14127 }
14128 433152 }
14129
14130 216576 }
14131
14132
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if(guyversion >= 37)
14133 {
14134
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.editorflags),f))
14135 {
14136 return qe_invalid;
14137 }
14138 216576 }
14139
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if ( guyversion < 37 ) { tempguy.editorflags = 0; }
14140
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if(guyversion >= 38)
14141 {
14142
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.attributes[12]),f))
14143 {
14144 return qe_invalid;
14145 }
14146
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.attributes[13]),f))
14147 {
14148 return qe_invalid;
14149 }
14150
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetl(&(tempguy.attributes[14]),f))
14151 {
14152 return qe_invalid;
14153 }
14154
14155 216576 }
14156
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if ( guyversion < 38 )
14157 {
14158 96768 tempguy.attributes[12] = 0;
14159 96768 tempguy.attributes[13] = 0;
14160 96768 tempguy.attributes[14] = 0;
14161 96768 }
14162
14163
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if ( guyversion >= 39 )
14164 {
14165
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 216576 times.
1949184 for ( int32_t q = 0; q < 8; q++ )
14166 {
14167
2/2
✓ Branch 0 taken 112619520 times.
✓ Branch 1 taken 1732608 times.
114352128 for ( int32_t w = 0; w < 65; w++ )
14168 {
14169
1/2
✓ Branch 0 taken 112619520 times.
✗ Branch 1 not taken.
112619520 if(!p_getc(&(tempguy.initD_label[q][w]),f))
14170 {
14171 return qe_invalid;
14172 }
14173 112619520 }
14174
2/2
✓ Branch 0 taken 112619520 times.
✓ Branch 1 taken 1732608 times.
114352128 for ( int32_t w = 0; w < 65; w++ )
14175 {
14176
1/2
✓ Branch 0 taken 112619520 times.
✗ Branch 1 not taken.
112619520 if(!p_getc(&(tempguy.weapon_initD_label[q][w]),f))
14177 {
14178 return qe_invalid;
14179 }
14180 112619520 }
14181 1732608 }
14182
14183
14184 216576 }
14185
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if ( guyversion < 39 ) //apply old InitD strings to both
14186 {
14187
2/2
✓ Branch 0 taken 774144 times.
✓ Branch 1 taken 96768 times.
870912 for ( int32_t q = 0; q < 8; q++ )
14188 {
14189 774144 sprintf(tempguy.initD_label[q],"InitD[%d]",q);
14190 774144 sprintf(tempguy.weapon_initD_label[q],"InitD[%d]",q);
14191 774144 }
14192 96768 }
14193
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if ( guyversion >= 40 )
14194 {
14195
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_igetw(&(tempguy.weaponscript),f))
14196 {
14197 return qe_invalid;
14198 }
14199 216576 }
14200
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if ( guyversion < 40 )
14201 {
14202 96768 tempguy.weaponscript = 0;
14203 96768 }
14204 //eweapon script InitD
14205
2/2
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
313344 if ( guyversion >= 41 )
14206 {
14207
2/2
✓ Branch 0 taken 1732608 times.
✓ Branch 1 taken 216576 times.
1949184 for ( int32_t q = 0; q < 8; q++ )
14208 {
14209
1/2
✓ Branch 0 taken 1732608 times.
✗ Branch 1 not taken.
1732608 if(!p_igetl(&(tempguy.weap_initiald[q]),f))
14210 {
14211 return qe_invalid;
14212 }
14213 1732608 }
14214
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if ( guy_cversion < 4 )
14215 {
14216 if ( tempguy.family == eeKEESE )
14217 {
14218
14219 if ( !tempguy.attributes[0] )
14220 {
14221 tempguy.attributes[15] = 120;
14222 tempguy.attributes[16] = 16;
14223
14224 }
14225 }
14226 if ( tempguy.family == eePEAHAT )
14227 {
14228 tempguy.attributes[15] = 80;
14229 tempguy.attributes[16] = 16;
14230 }
14231
14232 if ( tempguy.family == eeGHINI )
14233 {
14234 tempguy.attributes[15] = 120;
14235 tempguy.attributes[16] = 10;
14236 }
14237
14238 }
14239 216576 }
14240
14241
14242
14243 //default weapon sprites (quest version < 2.54)
14244 //port over old defaults -Z
14245
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion < 32)
14246 {
14247
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96768 times.
96768 if ( tempguy.wpnsprite <= 0 )
14248 {
14249
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81949 times.
✓ Branch 4 taken 762 times.
✓ Branch 5 taken 659 times.
✓ Branch 6 taken 1824 times.
✓ Branch 7 taken 1227 times.
✓ Branch 8 taken 2290 times.
✓ Branch 9 taken 195 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 423 times.
✓ Branch 12 taken 77 times.
✓ Branch 13 taken 865 times.
✓ Branch 14 taken 1715 times.
✓ Branch 15 taken 219 times.
✓ Branch 16 taken 311 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1455 times.
96768 switch(tempguy.weapon)
14250 {
14251 case wNone:
14252 81949 tempguy.wpnsprite = 0; break;
14253
14254 case wSword:
14255 case wBeam:
14256 case wBrang:
14257 case wBomb:
14258 case wSBomb:
14259 case wLitBomb:
14260 case wLitSBomb:
14261 case wArrow:
14262 case wFire:
14263 case wWhistle:
14264 case wBait:
14265 case wWand:
14266 case wMagic:
14267 case wCatching:
14268 case wWind:
14269 case wRefMagic:
14270 case wRefFireball:
14271 case wRefRock:
14272 case wHammer:
14273 case wHookshot:
14274 case wHSHandle:
14275 case wHSChain:
14276 case wSSparkle:
14277 case wFSparkle:
14278 case wSmack:
14279 case wPhantom:
14280 case wCByrna:
14281 case wRefBeam:
14282 case wStomp:
14283 case lwMax:
14284 case wScript1:
14285 case wScript2:
14286 case wScript3:
14287 case wScript4:
14288 case wScript5:
14289 case wScript6:
14290 case wScript7:
14291 case wScript8:
14292 case wScript9:
14293 case wScript10:
14294 case wIce:
14295 //Cannot use any of these weapons yet.
14296 tempguy.wpnsprite = -1;
14297 break;
14298
14299 case wEnemyWeapons:
14300 2720 case ewFireball: tempguy.wpnsprite = 17; break;
14301
14302 762 case ewArrow: tempguy.wpnsprite = 19; break;
14303 659 case ewBrang: tempguy.wpnsprite = 4; break;
14304 1824 case ewSword: tempguy.wpnsprite = 20; break;
14305 1227 case ewRock: tempguy.wpnsprite = 18; break;
14306 2290 case ewMagic: tempguy.wpnsprite = 21; break;
14307 195 case ewBomb: tempguy.wpnsprite = 78; break;
14308 77 case ewSBomb: tempguy.wpnsprite = 79; break;
14309 423 case ewLitBomb: tempguy.wpnsprite = 76; break;
14310 77 case ewLitSBomb: tempguy.wpnsprite = 77; break;
14311 865 case ewFireTrail: tempguy.wpnsprite = 80; break;
14312 1715 case ewFlame: tempguy.wpnsprite = 35; break;
14313 219 case ewWind: tempguy.wpnsprite = 36; break;
14314 311 case ewFlame2: tempguy.wpnsprite = 81; break;
14315 case ewFlame2Trail: tempguy.wpnsprite = 82; break;
14316 case ewIce: tempguy.wpnsprite = 83; break;
14317 1455 case ewFireball2: tempguy.wpnsprite = 17; break; //fireball (rising)
14318
14319
14320 default: break; //No assign.
14321 }
14322 96768 }
14323 96768 }
14324
14325 //default weapon fire sound (quest version < 2.54)
14326 //port over old defaults and zero new data. -Z
14327
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion < 34)
14328 {
14329
2/2
✓ Branch 0 taken 3096576 times.
✓ Branch 1 taken 96768 times.
3193344 for ( int32_t q = 0; q < 32; q++ )
14330 {
14331 3096576 tempguy.movement[q] = 0;
14332 3096576 tempguy.new_weapon[q] = 0;
14333
14334 3096576 }
14335
14336 //NPC Script attributes.
14337 96768 tempguy.script = 0; //No scripted enemies existed. -Z
14338
2/2
✓ Branch 0 taken 774144 times.
✓ Branch 1 taken 96768 times.
870912 for ( int32_t q = 0; q < 8; q++ ) tempguy.initD[q] = 0; //Script Data
14339
2/2
✓ Branch 0 taken 193536 times.
✓ Branch 1 taken 96768 times.
290304 for ( int32_t q = 0; q < 2; q++ ) tempguy.initA[q] = 0; //Script Data
14340
14341
2/2
✓ Branch 0 taken 1645056 times.
✓ Branch 1 taken 96768 times.
1741824 for ( int32_t q = 15; q < 32; q++) tempguy.attributes[q] = 0; //misc 16-32
14342
14343 //old default sounds
14344
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 96768 times.
96768 if ( tempguy.firesfx <= 0 )
14345 {
14346
16/20
✗ Branch 0 not taken.
✓ Branch 1 taken 2720 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 81949 times.
✓ Branch 4 taken 762 times.
✓ Branch 5 taken 659 times.
✓ Branch 6 taken 1824 times.
✓ Branch 7 taken 1227 times.
✓ Branch 8 taken 2290 times.
✓ Branch 9 taken 195 times.
✓ Branch 10 taken 77 times.
✓ Branch 11 taken 423 times.
✓ Branch 12 taken 77 times.
✓ Branch 13 taken 865 times.
✓ Branch 14 taken 1715 times.
✓ Branch 15 taken 219 times.
✓ Branch 16 taken 311 times.
✗ Branch 17 not taken.
✗ Branch 18 not taken.
✓ Branch 19 taken 1455 times.
96768 switch(tempguy.weapon)
14347 {
14348 case wNone:
14349 81949 tempguy.firesfx = 0; break;
14350
14351 case wSword:
14352 case wBeam:
14353 case wBrang:
14354 case wBomb:
14355 case wSBomb:
14356 case wLitBomb:
14357 case wLitSBomb:
14358 case wArrow:
14359 case wFire:
14360 case wWhistle:
14361 case wBait:
14362 case wWand:
14363 case wMagic:
14364 case wCatching:
14365 case wWind:
14366 case wRefMagic:
14367 case wRefFireball:
14368 case wRefRock:
14369 case wHammer:
14370 case wHookshot:
14371 case wHSHandle:
14372 case wHSChain:
14373 case wSSparkle:
14374 case wFSparkle:
14375 case wSmack:
14376 case wPhantom:
14377 case wCByrna:
14378 case wRefBeam:
14379 case wStomp:
14380 case lwMax:
14381 case wScript1:
14382 case wScript2:
14383 case wScript3:
14384 case wScript4:
14385 case wScript5:
14386 case wScript6:
14387 case wScript7:
14388 case wScript8:
14389 case wScript9:
14390 case wScript10:
14391 case wIce:
14392 //Cannot use any of these weapons yet.
14393 tempguy.firesfx = -1;
14394 break;
14395
14396 case wEnemyWeapons:
14397 2720 case ewFireball: tempguy.firesfx = 40; break;
14398
14399 762 case ewArrow: tempguy.firesfx = 1; break; //Ghost.zh has 0?
14400 659 case ewBrang: tempguy.firesfx = 4; break; //Ghost.zh has 0?
14401 1824 case ewSword: tempguy.firesfx = 20; break; //Ghost.zh has 0?
14402 1227 case ewRock: tempguy.firesfx = 51; break;
14403 2290 case ewMagic: tempguy.firesfx = 32; break;
14404 195 case ewBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14405 77 case ewSBomb: tempguy.firesfx = 3; break; //Ghost.zh has 0?
14406 423 case ewLitBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14407 77 case ewLitSBomb: tempguy.firesfx = 21; break; //Ghost.zh has 0?
14408 865 case ewFireTrail: tempguy.firesfx = 13; break;
14409 1715 case ewFlame: tempguy.firesfx = 13; break;
14410 219 case ewWind: tempguy.firesfx = 32; break;
14411 311 case ewFlame2: tempguy.firesfx = 13; break;
14412 case ewFlame2Trail: tempguy.firesfx = 13; break;
14413 case ewIce: tempguy.firesfx = 44; break;
14414 1455 case ewFireball2: tempguy.firesfx = 40; break; //fireball (rising)
14415
14416 //what about special attacks (e.g. summoning == 56)
14417 default: break; //No assign.
14418 }
14419 96768 }
14420 96768 }
14421
14422 //Port hardcoded hit sound to the enemy hitsfx defaults for older quests.
14423
4/6
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
✓ Branch 2 taken 216576 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 216576 times.
313344 if(Header->zelda_version <= 0x250 || ( Header->zelda_version > 0x250 && guyversion < 35 ))
14424 {
14425
2/2
✓ Branch 0 taken 13335 times.
✓ Branch 1 taken 83433 times.
96768 if ( tempguy.hitsfx == 0 ) tempguy.hitsfx = 11;
14426 96768 }
14427 //Keese and bat halt rates.
14428
3/4
✓ Branch 0 taken 96768 times.
✓ Branch 1 taken 216576 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 96768 times.
313344 if ( guyversion < 42 && guy_cversion < 4 )
14429 {
14430
14431
2/2
✓ Branch 0 taken 95530 times.
✓ Branch 1 taken 1238 times.
96768 if ( tempguy.family == eeKEESE )
14432 {
14433
14434
2/2
✓ Branch 0 taken 349 times.
✓ Branch 1 taken 889 times.
1238 if ( !tempguy.attributes[0] )
14435 {
14436 889 tempguy.attributes[15] = 120;
14437 889 tempguy.attributes[16] = 16;
14438
14439 889 }
14440 1238 }
14441
2/2
✓ Branch 0 taken 96325 times.
✓ Branch 1 taken 443 times.
96768 if ( tempguy.family == eePEAHAT )
14442 {
14443 443 tempguy.attributes[15] = 80;
14444 443 tempguy.attributes[16] = 16;
14445 443 }
14446
2/2
✓ Branch 0 taken 96579 times.
✓ Branch 1 taken 189 times.
96768 if ( tempguy.family == eeGHINI )
14447 {
14448 189 tempguy.attributes[15] = 120;
14449 189 tempguy.attributes[16] = 10;
14450 189 }
14451
14452
14453 96768 }
14454
14455
14456 //miscellaneous other corrections
14457 //fix the mirror wizzrobe -DD
14458
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 7)
14459 {
14460 if(i == eMWIZ)
14461 {
14462 tempguy.attributes[1] = 0;
14463 tempguy.attributes[3] = 1;
14464 }
14465 }
14466
14467
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 8)
14468 {
14469 if(i == eGLEEOK1 || i == eGLEEOK2 || i == eGLEEOK3 || i == eGLEEOK4 || i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14470 {
14471 // Some of these are deliberately different to NewDefault/defdata.cpp, by the way. -L
14472 tempguy.attributes[4] = 4; //neck length in segments
14473 tempguy.attributes[5] = 8; //neck offset from first body tile
14474 tempguy.attributes[6] = 40; //offset for each subsequent neck tile from the first neck tile
14475 tempguy.attributes[7] = 168; //head offset from first body tile
14476 tempguy.attributes[8] = 228; //flying head offset from first body tile
14477
14478 if(i == eGLEEOK1F || i == eGLEEOK2F || i == eGLEEOK3F || i == eGLEEOK4F)
14479 {
14480 tempguy.attributes[5] += 10; //neck offset from first body tile
14481 tempguy.attributes[7] -= 12; //head offset from first body tile
14482 }
14483 }
14484 }
14485
14486
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 10) // December 2007 - Dodongo CSet fix
14487 {
14488 if(get_bit(deprecated_rules,46) && tempguy.family==eeDONGO && tempguy.attributes[0]==0)
14489 tempguy.bosspal = spDIG;
14490 }
14491
14492
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 11) // December 2007 - Spinning Tile fix
14493 {
14494 if(tempguy.family==eeSPINTILE)
14495 {
14496 tempguy.flags |= guy_superman;
14497 tempguy.item_set = 0; // Don't drop items
14498 tempguy.step = 300;
14499 }
14500 }
14501
14502
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 12) // October 2008 - Flashing Bubble, Rope 2, and Ghini 2 fix
14503 {
14504 if(get_bit(deprecated_rules, qr_NOROPE2FLASH_DEP))
14505 {
14506 if(tempguy.family==eeROPE)
14507 {
14508 tempguy.flags &= ~guy_flashing;
14509 }
14510 }
14511
14512 if(get_bit(deprecated_rules, qr_NOBUBBLEFLASH_DEP))
14513 {
14514 if(tempguy.family==eeBUBBLE)
14515 {
14516 tempguy.flags &= ~guy_flashing;
14517 }
14518 }
14519
14520 if((tempguy.family==eeGHINI)&&(tempguy.attributes[0]))
14521 {
14522 if(get_bit(deprecated_rules, qr_GHINI2BLINK_DEP))
14523 {
14524 tempguy.flags |= guy_blinking;
14525 }
14526
14527 if(get_bit(deprecated_rules, qr_PHANTOMGHINI2_DEP))
14528 {
14529 tempguy.flags |= guy_transparent;
14530 }
14531 }
14532 }
14533
14534
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 15) // July 2009 - Guy Fire and Fairy fix
14535 {
14536 if(i==gFIRE)
14537 {
14538 tempguy.e_anim = aFLIP;
14539 tempguy.e_frate = 24;
14540 }
14541
14542 if(i==gFAIRY)
14543 {
14544 tempguy.e_anim = a2FRM;
14545 tempguy.e_frate = 16;
14546 }
14547 }
14548
14549
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 16) // November 2009 - Super Enemy Editor part 1
14550 {
14551 if(i==0) Z_message("Updating guys to version 16...\n");
14552
14553 update_guy_1(&tempguy);
14554
14555 if(i==eMPOLSV)
14556 {
14557 tempguy.defense[edefARROW] = edCHINK;
14558 tempguy.defense[edefMAGIC] = ed1HKO;
14559 tempguy.defense[edefREFMAGIC] = ed1HKO;
14560 }
14561 }
14562
14563
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 17) // December 2009
14564 {
14565 if(tempguy.family==eePROJECTILE)
14566 {
14567 tempguy.attributes[0] = 0;
14568 }
14569 }
14570
14571
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 18) // January 2010
14572 {
14573 bool boss = (tempguy.family == eeAQUA || tempguy.family==eeDONGO || tempguy.family == eeMANHAN || tempguy.family == eeGHOMA || tempguy.family==eeDIG
14574 || tempguy.family == eeGLEEOK || tempguy.family==eePATRA || tempguy.family == eeGANON || tempguy.family==eeMOLD);
14575
14576 tempguy.hitsfx = (boss && tempguy.family != eeMOLD && tempguy.family != eeDONGO && tempguy.family != eeDIG) ? WAV_GASP : 0;
14577 tempguy.deadsfx = (boss && (tempguy.family != eeDIG || tempguy.attributes[9] == 0)) ? WAV_GASP : WAV_EDEAD;
14578
14579 if(tempguy.family == eeAQUA)
14580 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eRAQUAM].defense[j];
14581 else if(tempguy.family == eeMANHAN)
14582 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eMANHAN].defense[j];
14583 else if(tempguy.family==eePATRA)
14584 for(int32_t j=0; j<edefLAST; j++) tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14585 else if(tempguy.family==eeGHOMA)
14586 {
14587 for(int32_t j=0; j<edefLAST; j++)
14588 tempguy.defense[j] = default_guys[eGOHMA1].defense[j];
14589
14590 tempguy.defense[edefARROW] = ((tempguy.attributes[0]==3) ? edCHINKL8 : (tempguy.attributes[0]==2) ? edCHINKL4 : 0);
14591
14592 if(tempguy.attributes[0]==3 && !tempguy.weapon) tempguy.weapon = ewFlame;
14593
14594 tempguy.attributes[0]--;
14595 }
14596 else if(tempguy.family == eeGLEEOK)
14597 {
14598 for(int32_t j=0; j<edefLAST; j++)
14599 tempguy.defense[j] = default_guys[eGLEEOK1].defense[j];
14600
14601 if(tempguy.attributes[2]==1 && !tempguy.weapon) tempguy.weapon = ewFlame;
14602 }
14603 else if(tempguy.family == eeARMOS)
14604 {
14605 tempguy.family=eeWALK;
14606 tempguy.hrate = 0;
14607 tempguy.attributes[9] = tempguy.attributes[0];
14608 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] = tempguy.attributes[6] = tempguy.attributes[7] = 0;
14609 tempguy.attributes[8] = e9tARMOS;
14610 }
14611 else if(tempguy.family == eeGHINI && !tempguy.attributes[0])
14612 {
14613 tempguy.family=eeWALK;
14614 tempguy.hrate = 0;
14615 tempguy.attributes[0] = tempguy.attributes[1] = tempguy.attributes[2] = tempguy.attributes[3] = tempguy.attributes[4] = tempguy.attributes[5] =
14616 tempguy.attributes[6] = tempguy.attributes[7] = tempguy.attributes[8] = tempguy.attributes[9] = 0;
14617 }
14618
14619 // Spawn animation flags
14620 if(tempguy.family == eeWALK && (tempguy.flags&guy_armos || tempguy.flags&guy_ghini))
14621 tempguy.flags |= guy_fade_flicker;
14622 else
14623 tempguy.flags &= (guy_flags)0x0F00000F; // Get rid of the unused flags!
14624 }
14625
14626
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 20) // April 2010
14627 {
14628 if(tempguy.family == eeTRAP)
14629 {
14630 tempguy.attributes[1] = tempguy.attributes[9];
14631
14632 if(tempguy.attributes[9]>=1)
14633 {
14634 tempguy.attributes[0]++;
14635 }
14636
14637 tempguy.attributes[9] = 0;
14638 }
14639
14640 // Bomb Blast fix
14641 if(tempguy.weapon==ewBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14642 tempguy.weapon = ewLitBomb;
14643 else if(tempguy.weapon==ewSBomb && tempguy.family!=eeROPE && (tempguy.family!=eeWALK || tempguy.attributes[1] != e2tBOMBCHU))
14644 tempguy.weapon = ewLitSBomb;
14645 }
14646
14647
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 21) // September 2011
14648 {
14649 if(tempguy.family == eeKEESE || tempguy.family == eeKEESETRIB)
14650 {
14651 if(tempguy.family == eeKEESETRIB)
14652 {
14653 tempguy.family = eeKEESE;
14654 tempguy.attributes[1] = e2tKEESETRIB;
14655 tempguy.attributes[0] = 0;
14656 }
14657
14658 tempguy.rate = 2;
14659 tempguy.hrate = 8;
14660 tempguy.homing = 0;
14661 tempguy.step= (tempguy.family == eeKEESE && tempguy.attributes[0] ? 100:62);
14662 }
14663 else if(tempguy.family == eePEAHAT || tempguy.family==eePATRA)
14664 {
14665 if(tempguy.family == eePEAHAT)
14666 {
14667 tempguy.rate = 4;
14668 tempguy.step = 62;
14669 }
14670 else
14671 tempguy.step = 25;
14672
14673 tempguy.hrate = 8;
14674 tempguy.homing = 0;
14675 }
14676 else if(tempguy.family == eeDIG || tempguy.family == eeMANHAN)
14677 {
14678 if(tempguy.family == eeMANHAN)
14679 tempguy.step=50;
14680
14681 tempguy.hrate = 16;
14682 tempguy.homing = 0;
14683 }
14684 else if(tempguy.family == eeGLEEOK)
14685 {
14686 tempguy.rate = 2;
14687 tempguy.homing = 0;
14688 tempguy.hrate = 9;
14689 tempguy.step=89;
14690 }
14691 else if(tempguy.family == eeGHINI)
14692 {
14693 tempguy.rate = 4;
14694 tempguy.hrate = 12;
14695 tempguy.step=62;
14696 tempguy.homing = 0;
14697 }
14698
14699 // Bigdig random rate fix
14700 if(tempguy.family==eeDIG && tempguy.attributes[9]==1)
14701 {
14702 tempguy.rate = 2;
14703 }
14704 }
14705
14706
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(guyversion < 24) // November 2012
14707 {
14708 if(tempguy.family==eeLANM)
14709 tempguy.attributes[2] = 1;
14710 else if(tempguy.family==eeMOLD)
14711 tempguy.attributes[1] = 0;
14712 }
14713
14714
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion < 33) //Whistle defence did not exist before this version of 2.54. -Z
14715 {
14716
2/2
✓ Branch 0 taken 1339 times.
✓ Branch 1 taken 95429 times.
96768 if(tempguy.family!=eeDIG)
14717 {
14718 95429 tempguy.defense[edefWhistle] = edIGNORE; //Might need to be ignore, universally.
14719 95429 }
14720
14721 96768 }
14722 // does not seem to solve the issue!
14723
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if ( Header->zelda_version <= 0x210 )
14724 {
14725 al_trace("Detected version %d for dodongo patch.\n",Header->zelda_version);
14726 if ( tempguy.family == eeDONGO )
14727 {
14728 tempguy.deadsfx = 15; //In 2.10 and earlier, Dodongos used this as their death sound.
14729 }
14730 }
14731
14732
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion >= 42)
14733 {
14734
2/2
✓ Branch 0 taken 214016 times.
✓ Branch 1 taken 2560 times.
216576 if(guyversion >= 47)
14735 {
14736
1/2
✓ Branch 0 taken 214016 times.
✗ Branch 1 not taken.
214016 if(!p_igetl(&(tempguy.moveflags),f))
14737 {
14738 return qe_invalid;
14739 }
14740 214016 }
14741 else
14742 {
14743 byte fl;
14744
1/2
✓ Branch 0 taken 2560 times.
✗ Branch 1 not taken.
2560 if(!p_getc(&fl,f))
14745 {
14746 return qe_invalid;
14747 }
14748 2560 tempguy.moveflags = (move_flags)fl;
14749 }
14750 216576 }
14751 else
14752 {
14753
7/8
✓ Branch 0 taken 2771 times.
✓ Branch 1 taken 76150 times.
✓ Branch 2 taken 2607 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 922 times.
✓ Branch 5 taken 611 times.
✓ Branch 6 taken 475 times.
✓ Branch 7 taken 13232 times.
96768 switch(tempguy.family)
14754 {
14755 //No gravity; floats over pits
14756 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14757 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14758 //Special (bosses, etc)
14759 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14760 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14761 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14762 76150 tempguy.moveflags = move_can_pitwalk;
14763 76150 break;
14764 //No gravity, but falls in pits
14765 case eeLEV:
14766 922 tempguy.moveflags = move_can_pitfall;
14767 922 break;
14768 //Bosses that respect pits
14769 case eeDONGO:
14770 611 tempguy.moveflags = move_obeys_grav;
14771 611 break;
14772 case eeLANM:
14773 475 tempguy.moveflags = move_none;
14774 475 break;
14775 //Gravity, floats over pits
14776 case eeWIZZ: case eeWALLM: case eeGHINI:
14777 2607 tempguy.moveflags = move_obeys_grav | move_can_pitwalk;
14778 2607 break;
14779 //Gravity and falls in pits
14780 case eeWALK:
14781
4/4
✓ Branch 0 taken 12569 times.
✓ Branch 1 taken 663 times.
✓ Branch 2 taken 508 times.
✓ Branch 3 taken 12061 times.
13232 if (tempguy.attributes[8]==e9tPOLSVOICE||tempguy.attributes[8]==e9tVIRE)
14782 1171 break;
14783 [[fallthrough]];
14784 case eeOTHER:
14785 case eeSCRIPT01: case eeSCRIPT02: case eeSCRIPT03: case eeSCRIPT04: case eeSCRIPT05:
14786 case eeSCRIPT06: case eeSCRIPT07: case eeSCRIPT08: case eeSCRIPT09: case eeSCRIPT10:
14787 case eeSCRIPT11: case eeSCRIPT12: case eeSCRIPT13: case eeSCRIPT14: case eeSCRIPT15:
14788 case eeSCRIPT16: case eeSCRIPT17: case eeSCRIPT18: case eeSCRIPT19: case eeSCRIPT20:
14789 case eeFFRIENDLY01: case eeFFRIENDLY02: case eeFFRIENDLY03: case eeFFRIENDLY04: case eeFFRIENDLY05:
14790 case eeFFRIENDLY06: case eeFFRIENDLY07: case eeFFRIENDLY08: case eeFFRIENDLY09: case eeFFRIENDLY10:
14791 14832 tempguy.moveflags = move_obeys_grav | move_can_pitfall;
14792 14832 }
14793 }
14794
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion < 43)
14795 {
14796
2/2
✓ Branch 0 taken 78757 times.
✓ Branch 1 taken 18011 times.
96768 switch(tempguy.family)
14797 {
14798 //No gravity; floats over pits
14799 case eeTEK: case eePEAHAT: case eeROCK: case eeTRAP:
14800 case eePROJECTILE: case eeSPINTILE: case eeKEESE: case eeFIRE:
14801 //Special (bosses, etc)
14802 case eeFAIRY: case eeGUY: case eeNONE: case eeZORA:
14803 case eeAQUA: case eeDIG: case eeGHOMA: case eeGANON:
14804 case eePATRA: case eeGLEEOK: case eeMOLD: case eeMANHAN:
14805 case eeWIZZ: case eeWALLM: case eeGHINI:
14806 //Gravity, floats over pits
14807 78757 tempguy.moveflags |= move_can_waterwalk;
14808 78757 tempguy.moveflags |= move_can_pitwalk;
14809 78757 break;
14810 }
14811 96768 }
14812
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if (guyversion < 44)
14813 {
14814
2/2
✓ Branch 0 taken 95897 times.
✓ Branch 1 taken 871 times.
96768 if ( tempguy.family == eeGHOMA )
14815 {
14816 871 tempguy.flags |= guy_fade_instant;
14817 871 }
14818 96768 }
14819
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if (guyversion > 44)
14820 {
14821
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_getc(&(tempguy.spr_shadow),f))
14822 {
14823 return qe_invalid;
14824 }
14825
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_getc(&(tempguy.spr_death),f))
14826 {
14827 return qe_invalid;
14828 }
14829
1/2
✓ Branch 0 taken 216576 times.
✗ Branch 1 not taken.
216576 if(!p_getc(&(tempguy.spr_spawn),f))
14830 {
14831 return qe_invalid;
14832 }
14833 216576 }
14834 else
14835 {
14836
2/2
✓ Branch 0 taken 96392 times.
✓ Branch 1 taken 376 times.
96768 tempguy.spr_shadow = (tempguy.family==eeROCK && tempguy.attributes[9]==1) ? iwLargeShadow : iwShadow;
14837 96768 tempguy.spr_death = iwDeath;
14838 96768 tempguy.spr_spawn = iwSpawn;
14839 }
14840
14841
2/2
✓ Branch 0 taken 216576 times.
✓ Branch 1 taken 96768 times.
313344 if(guyversion < 46)
14842 {
14843
4/4
✓ Branch 0 taken 13232 times.
✓ Branch 1 taken 83536 times.
✓ Branch 2 taken 12569 times.
✓ Branch 3 taken 663 times.
96768 if(tempguy.family == eeWALK && tempguy.attributes[8] == e9tPOLSVOICE)
14844 {
14845 663 tempguy.moveflags |= move_can_waterwalk;
14846 663 }
14847 96768 }
14848
14849
2/2
✓ Branch 0 taken 214016 times.
✓ Branch 1 taken 99328 times.
313344 if (guyversion < 47)
14850 {
14851
4/4
✓ Branch 0 taken 1369 times.
✓ Branch 1 taken 97959 times.
✓ Branch 2 taken 816 times.
✓ Branch 3 taken 553 times.
99328 if (tempguy.family == eeDIG && tempguy.attributes[9]!=1)
14852 {
14853 553 tempguy.flags |= guy_ignore_kill_all;
14854 553 }
14855 99328 }
14856
14857
2/2
✓ Branch 0 taken 19456 times.
✓ Branch 1 taken 293888 times.
313344 if (guyversion < 48)
14858 {
14859
8/8
✓ Branch 0 taken 33954 times.
✓ Branch 1 taken 259934 times.
✓ Branch 2 taken 32821 times.
✓ Branch 3 taken 1133 times.
✓ Branch 4 taken 31676 times.
✓ Branch 5 taken 1145 times.
✓ Branch 6 taken 1189 times.
✓ Branch 7 taken 30487 times.
293888 if (tempguy.family == eeWALK && (tempguy.attributes[6]==e7tPERMJINX || tempguy.attributes[6]==e7tTEMPJINX || tempguy.attributes[6]==e7tUNJINX)) //BUBBLE CHECK
14860 {
14861
3/4
✗ Branch 0 not taken.
✓ Branch 1 taken 1702 times.
✓ Branch 2 taken 1705 times.
✓ Branch 3 taken 60 times.
3467 switch (tempguy.attributes[7]) {
14862 case 0: //Sword
14863 1702 tempguy.attributes[7] = e8tSWORD;
14864 1702 break;
14865 case 1: //Item
14866 1705 tempguy.attributes[7] = e8tITEM;
14867 1705 break;
14868 case 2: //Both
14869 60 tempguy.attributes[7] = e8tSWORD|e8tITEM;
14870 60 break;
14871 default: //this can actually happen since Misc8 can be set to any number.
14872 tempguy.attributes[7] = 0;
14873 break;
14874 }
14875 3467 }
14876 293888 }
14877
14878
1/2
✓ Branch 0 taken 313344 times.
✗ Branch 1 not taken.
313344 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
14879 {
14880 tempguy.script = 0;
14881 for(int q = 0; q < 8; ++q)
14882 tempguy.initD[q] = 0;
14883 }
14884 313344 guysbuf[i] = tempguy;
14885 313344 }
14886 612 }
14887
14888 612 return 0;
14889 694 }
14890
14891 void update_guy_1(guydata *tempguy) // November 2009
14892 {
14893 bool doesntcount = false;
14894 tempguy->flags &= ~guy_weak_arrow; // Formerly 'weak to arrow' which wasn't implemented
14895
14896 switch(tempguy->family)
14897 {
14898 case 1: //eeWALK
14899 switch(tempguy->attributes[9])
14900 {
14901 case 0: //Stalfos
14902 if(tempguy->attributes[0]==1) // Fires four projectiles at once
14903 tempguy->attributes[0]=4;
14904
14905 break;
14906
14907 case 1: //Darknut
14908 goto darknuts;
14909 break;
14910 }
14911
14912 tempguy->attributes[9] = 0;
14913 break;
14914
14915 case 2: //eeSHOOT
14916 tempguy->family = eeWALK;
14917
14918 switch(tempguy->attributes[9])
14919 {
14920 case 0: //Octorok
14921 if(tempguy->attributes[0]==1||tempguy->attributes[0]==2)
14922 {
14923 tempguy->attributes[0]=e1tFIREOCTO;
14924 tempguy->attributes[1]=e2tFIREOCTO;
14925 }
14926 else tempguy->attributes[0] = 0;
14927
14928 tempguy->attributes[5]=tempguy->attributes[3];
14929 tempguy->attributes[3]=tempguy->attributes[2];
14930 tempguy->attributes[2]=0;
14931 break;
14932
14933 case 1: // Moblin
14934 tempguy->attributes[0] = 0;
14935 break;
14936
14937 case 2: //Lynel
14938 tempguy->attributes[5]=tempguy->attributes[0]+1;
14939 tempguy->attributes[0]=0;
14940 break;
14941
14942 case 3: //Stalfos 2
14943 if(tempguy->attributes[0]==1) // Fires four projectiles at once
14944 tempguy->attributes[0]=e1t4SHOTS;
14945 else tempguy->attributes[0] = 0;
14946
14947 break;
14948
14949 case 4: //Darknut 5
14950 darknuts:
14951 tempguy->defense[edefFIRE] = edIGNORE;
14952 tempguy->defense[edefBRANG] = edSTUNORCHINK;
14953 tempguy->defense[edefHOOKSHOT] = 0;
14954 tempguy->defense[edefARROW] = tempguy->defense[edefBYRNA] = tempguy->defense[edefREFROCK] =
14955 tempguy->defense[edefMAGIC] = tempguy->defense[edefSTOMP] = edCHINK;
14956
14957 if(tempguy->attributes[0]==1)
14958 tempguy->attributes[0]=2;
14959 else if(tempguy->attributes[0]==2)
14960 {
14961 tempguy->attributes[3]=tempguy->attributes[2];
14962 tempguy->attributes[2]=tempguy->attributes[1];
14963 tempguy->attributes[1]=e2tSPLIT;
14964 tempguy->attributes[0] = 0;
14965 }
14966 else tempguy->attributes[0] = 0;
14967
14968 tempguy->flags |= guy_shield_front;
14969
14970 if(get_bit(deprecated_rules,qr_BRKBLSHLDS_DEP))
14971 tempguy->flags |= guy_bkshield;
14972
14973 break;
14974 }
14975
14976 tempguy->attributes[9] = 0;
14977 break;
14978
14979 /*
14980 case 9: //eeARMOS
14981 tempguy->family = eeWALK;
14982 break;
14983 */
14984 case 11: //eeGEL
14985 case 33: //eeGELTRIB
14986 if(tempguy->family==33)
14987 {
14988 tempguy->attributes[3] = 1;
14989
14990 if(get_bit(deprecated_rules, qr_OLDTRIBBLES_DEP)) //Old Tribbles
14991 tempguy->attributes[2] = tempguy->attributes[1];
14992
14993 tempguy->attributes[1] = e2tTRIBBLE;
14994 }
14995 else
14996 {
14997 tempguy->attributes[3] = 0;
14998 tempguy->attributes[2] = 0;
14999 tempguy->attributes[1] = 0;
15000 }
15001
15002 tempguy->family = eeWALK;
15003
15004 if(tempguy->attributes[0])
15005 {
15006 tempguy->attributes[0]=1;
15007 tempguy->weapon = ewFireTrail;
15008 }
15009
15010 break;
15011
15012 case 34: //eeZOLTRIB
15013 case 12: //eeZOL
15014 tempguy->attributes[3]=tempguy->attributes[2];
15015 tempguy->attributes[2]=tempguy->attributes[1];
15016 tempguy->family = eeWALK;
15017 tempguy->attributes[1]=e2tSPLITHIT;
15018
15019 if(tempguy->attributes[0])
15020 {
15021 tempguy->attributes[0]=1;
15022 tempguy->weapon = ewFireTrail;
15023 }
15024
15025 break;
15026
15027 case 13: //eeROPE
15028 tempguy->family = eeWALK;
15029 tempguy->attributes[8] = e9tROPE;
15030
15031 if(tempguy->attributes[0])
15032 {
15033 tempguy->attributes[3] = tempguy->attributes[2];
15034 tempguy->attributes[2] = tempguy->attributes[1];
15035 tempguy->attributes[1] = e2tBOMBCHU;
15036 }
15037
15038 tempguy->attributes[0] = 0;
15039 break;
15040
15041 case 14: //eeGORIYA
15042 tempguy->family = eeWALK;
15043
15044 if(tempguy->attributes[0]!=2) tempguy->attributes[0] = 0;
15045
15046 break;
15047
15048 case 17: //eeBUBBLE
15049 tempguy->family = eeWALK;
15050 tempguy->attributes[7] = tempguy->attributes[1];
15051 tempguy->attributes[6] = tempguy->attributes[0] + 1;
15052 tempguy->attributes[0] = tempguy->attributes[1] = 0;
15053
15054 //fallthrogh
15055 case eeTRAP:
15056 case eeROCK:
15057 doesntcount = true;
15058 break;
15059
15060 case 35: //eeVIRETRIB
15061 case 18: //eeVIRE
15062 tempguy->family = eeWALK;
15063 tempguy->attributes[3]=tempguy->attributes[2];
15064 tempguy->attributes[2]=tempguy->attributes[1];
15065 tempguy->attributes[1]=e2tSPLITHIT;
15066 tempguy->attributes[8]=e9tVIRE;
15067 break;
15068
15069 case 19: //eeLIKE
15070 tempguy->family = eeWALK;
15071 tempguy->attributes[6] = e7tEATITEMS;
15072 tempguy->attributes[7]=95;
15073 break;
15074
15075 case 20: //eePOLSV
15076 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15077 tempguy->defense[edefBOMB] = tempguy->defense[edefSBOMB] = tempguy->defense[edefFIRE] = edIGNORE;
15078 tempguy->defense[edefMAGIC] = tempguy->defense[edefBYRNA] = edCHINK;
15079 tempguy->defense[edefARROW] = ed1HKO;
15080 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15081 tempguy->family = eeWALK;
15082 tempguy->attributes[8] = e9tPOLSVOICE;
15083 tempguy->rate = 4;
15084 tempguy->homing = 32;
15085 tempguy->hrate = 10;
15086 tempguy->grumble = 0;
15087 break;
15088
15089 case eeWIZZ:
15090 if(tempguy->attributes[3])
15091 {
15092 for(int32_t i=0; i < edefLAST; i++)
15093 tempguy->defense[i] = (i != edefREFBEAM && i != edefREFMAGIC && i != edefQUAKE) ? edIGNORE : 0;
15094 }
15095 else
15096 {
15097 tempguy->defense[edefBRANG] = edSTUNORCHINK;
15098 tempguy->defense[edefMAGIC] = edCHINK;
15099 tempguy->defense[edefHOOKSHOT] = edSTUNONLY;
15100 tempguy->defense[edefARROW] = tempguy->defense[edefFIRE] =
15101 tempguy->defense[edefWAND] = tempguy->defense[edefBYRNA] = edIGNORE;
15102 }
15103
15104 break;
15105
15106 case eePEAHAT:
15107 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15108
15109 if(!(tempguy->flags & guy_bhit))
15110 tempguy->defense[edefBRANG] = edSTUNONLY;
15111
15112 break;
15113
15114 case eeLEV:
15115 tempguy->defense[edefSTOMP] = edCHINK;
15116 break;
15117 }
15118
15119 // Old flags
15120 if(tempguy->flags & guy_superman)
15121 {
15122 for(int32_t i = 0; i < edefLAST; i++)
15123 if(!(i==edefSBOMB && (tempguy->flags & guy_sbombonly)))
15124 tempguy->defense[i] = (i==edefBRANG && tempguy->defense[i] != edIGNORE
15125 && tempguy->family != eeROCK && tempguy->family != eeTRAP
15126 && tempguy->family != eePROJECTILE) ? edSTUNORIGNORE : edIGNORE;
15127 }
15128
15129 tempguy->flags &= ~(guy_superman|guy_sbombonly);
15130
15131 if(doesntcount)
15132 tempguy->flags |= (guy_doesnt_count);
15133 }
15134
15135
15136 1154920 int32_t readmapscreen_old(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version)
15137 {
15138 byte tempbyte, padding;
15139 int32_t extras, secretcombos;
15140
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->valid),f))
15141 {
15142 return qe_invalid;
15143 }
15144
15145
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->guy),f))
15146 return qe_invalid;
15147 1154920 temp_mapscr->guytile = -1; //signal to use default guy values
15148
2/2
✓ Branch 0 taken 1154343 times.
✓ Branch 1 taken 577 times.
1154920 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
15149
4/4
✓ Branch 0 taken 577 times.
✓ Branch 1 taken 1154343 times.
✓ Branch 2 taken 42 times.
✓ Branch 3 taken 535 times.
1154920 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
15150
15151
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<146)))
15152 {
15153
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
22176 if(!p_getc(&tempbyte,f))
15154 {
15155 return qe_invalid;
15156 }
15157
15158 22176 temp_mapscr->str=tempbyte;
15159 22176 }
15160 else
15161 {
15162
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1132744 times.
1132744 if(!p_igetw(&(temp_mapscr->str),f))
15163 {
15164 return qe_invalid;
15165 }
15166 }
15167
15168
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->room),f))
15169 {
15170 return qe_invalid;
15171 }
15172
15173
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->item),f))
15174 {
15175 return qe_invalid;
15176 }
15177
15178
3/6
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 626416 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if(Header->zelda_version < 0x211 || (Header->zelda_version == 0x211 && Header->build < 14))
15179 {
15180 528504 temp_mapscr->hasitem = (temp_mapscr->item != 0) ? 1 : 0;
15181 528504 }
15182 else
15183 {
15184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->hasitem),f))
15185 return qe_invalid;
15186 }
15187
15188
3/4
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1157640 if((Header->zelda_version < 0x192)||
15189
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
1132744 ((Header->zelda_version == 0x192)&&(Header->build<154)))
15190 {
15191
1/2
✓ Branch 0 taken 22176 times.
✗ Branch 1 not taken.
22176 if(!p_getc(&tempbyte,f))
15192 {
15193 return qe_invalid;
15194 }
15195 22176 }
15196
15197
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->tilewarptype[0]),f))
15198 {
15199 return qe_invalid;
15200 }
15201
15202
2/2
✓ Branch 0 taken 1130024 times.
✓ Branch 1 taken 24896 times.
1154920 if(Header->zelda_version < 0x193)
15203 {
15204
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 24896 times.
24896 if(!p_getc(&tempbyte,f))
15205 {
15206 return qe_invalid;
15207 }
15208 24896 }
15209
15210
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15211 {
15212
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15213 {
15214
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
15215 {
15216 return qe_invalid;
15217 }
15218 1879248 }
15219 626416 }
15220 else
15221 {
15222 528504 temp_mapscr->tilewarptype[1]=0;
15223 528504 temp_mapscr->tilewarptype[2]=0;
15224 528504 temp_mapscr->tilewarptype[3]=0;
15225 }
15226
15227
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15228 {
15229
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1132744 times.
1132744 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
15230 {
15231 return qe_invalid;
15232 }
15233 1132744 }
15234
15235
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->warpreturnx[0]),f))
15236 {
15237 return qe_invalid;
15238 }
15239
15240 1154920 temp_mapscr->warpreturnx[1]=0;
15241 1154920 temp_mapscr->warpreturnx[2]=0;
15242 1154920 temp_mapscr->warpreturnx[3]=0;
15243
15244
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15245 {
15246
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15247 {
15248
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
15249 {
15250 return qe_invalid;
15251 }
15252 1879248 }
15253 626416 }
15254
15255
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->warpreturny[0]),f))
15256 {
15257 return qe_invalid;
15258 }
15259
15260 1154920 temp_mapscr->warpreturny[1]=0;
15261 1154920 temp_mapscr->warpreturny[2]=0;
15262 1154920 temp_mapscr->warpreturny[3]=0;
15263
15264
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15265 {
15266
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15267 {
15268
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
15269 {
15270 return qe_invalid;
15271 }
15272 1879248 }
15273
15274
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(version>=18)
15275 {
15276
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&temp_mapscr->warpreturnc,f))
15277 {
15278 return qe_invalid;
15279 }
15280 626416 }
15281 else
15282 {
15283 byte temp;
15284
15285 if(!p_getc(&temp,f))
15286 {
15287 return qe_invalid;
15288 }
15289
15290 temp_mapscr->warpreturnc=temp<<8|temp;
15291 }
15292 626416 }
15293
15294
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->stairx),f))
15295
15296 {
15297 return qe_invalid;
15298 }
15299
15300
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->stairy),f))
15301 {
15302 return qe_invalid;
15303 }
15304
15305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->itemx),f))
15306 {
15307 return qe_invalid;
15308 }
15309
15310
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->itemy),f))
15311 {
15312 return qe_invalid;
15313 }
15314
15315
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version > 15) // February 2009
15316 {
15317
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&(temp_mapscr->color),f))
15318 {
15319 return qe_invalid;
15320 }
15321 626416 }
15322 else
15323 {
15324
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 528504 times.
528504 if(!p_getc(& tempbyte,f))
15325 {
15326 return qe_invalid;
15327 }
15328
15329 528504 temp_mapscr->color = (word) tempbyte;
15330 }
15331
15332
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->enemyflags),f))
15333 {
15334 return qe_invalid;
15335 }
15336
15337
2/2
✓ Branch 0 taken 4619680 times.
✓ Branch 1 taken 1154920 times.
5774600 for(int32_t k=0; k<4; k++)
15338 {
15339
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4619680 times.
4619680 if(!p_getc(&(temp_mapscr->door[k]),f))
15340 {
15341 return qe_invalid;
15342
15343 }
15344 4619680 }
15345
15346
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version <= 11)
15347 {
15348
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15349 {
15350 return qe_invalid;
15351 }
15352
15353 528504 temp_mapscr->tilewarpdmap[0]=(word)tempbyte;
15354
15355
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15356 {
15357 for(int32_t i=1; i<4; i++)
15358 {
15359 if(!p_getc(&(tempbyte),f))
15360 {
15361 return qe_invalid;
15362 }
15363
15364 temp_mapscr->tilewarpdmap[i]=(word)tempbyte;
15365 }
15366 }
15367 else
15368 {
15369 528504 temp_mapscr->tilewarpdmap[1]=0;
15370 528504 temp_mapscr->tilewarpdmap[2]=0;
15371 528504 temp_mapscr->tilewarpdmap[3]=0;
15372 }
15373 528504 }
15374 else
15375 {
15376
2/2
✓ Branch 0 taken 2505664 times.
✓ Branch 1 taken 626416 times.
3132080 for(int32_t i=0; i<4; i++)
15377 {
15378
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2505664 times.
2505664 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
15379 {
15380 return qe_invalid;
15381 }
15382 2505664 }
15383 }
15384
15385
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->tilewarpscr[0]),f))
15386 {
15387 return qe_invalid;
15388 }
15389
15390
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15391 {
15392
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15393 {
15394
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
15395 {
15396 return qe_invalid;
15397 }
15398 1879248 }
15399 626416 }
15400 else
15401 {
15402 528504 temp_mapscr->tilewarpscr[1]=0;
15403 528504 temp_mapscr->tilewarpscr[2]=0;
15404 528504 temp_mapscr->tilewarpscr[3]=0;
15405 }
15406
15407
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version >= 15)
15408 {
15409
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
15410 {
15411 return qe_invalid;
15412 }
15413 626416 }
15414 else
15415 {
15416 528504 temp_mapscr->tilewarpoverlayflags=0;
15417 }
15418
15419
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->exitdir),f))
15420 {
15421 return qe_invalid;
15422 }
15423
15424
2/2
✓ Branch 0 taken 1130024 times.
✓ Branch 1 taken 24896 times.
1154920 if(Header->zelda_version < 0x193)
15425 {
15426
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&tempbyte,f))
15427 {
15428 return qe_invalid;
15429 }
15430
15431 24896 }
15432
15433
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1152200 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version == 0x192)&&(Header->build>145)&&(Header->build<154))
15434 {
15435 if(!p_getc(&padding,f))
15436 {
15437 return qe_invalid;
15438 }
15439 }
15440
15441
2/2
✓ Branch 0 taken 11549200 times.
✓ Branch 1 taken 1154920 times.
12704120 for(int32_t k=0; k<10; k++)
15442 {
15443 /*
15444 if (!temp_mapscr->enemy[k])
15445 {
15446 continue;
15447 }
15448 */
15449
5/6
✓ Branch 0 taken 11327440 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11300240 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11549200 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<10)))
15450 {
15451
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 221760 times.
221760 if(!p_getc(&tempbyte,f))
15452 {
15453 return qe_invalid;
15454 }
15455
15456 221760 temp_mapscr->enemy[k]=tempbyte;
15457 221760 }
15458 else
15459 {
15460
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 11327440 times.
11327440 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
15461 {
15462 return qe_invalid;
15463 }
15464 }
15465
15466
5/6
✓ Branch 0 taken 11327440 times.
✓ Branch 1 taken 221760 times.
✓ Branch 2 taken 27200 times.
✓ Branch 3 taken 11300240 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 27200 times.
11549200 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<108)))
15467 {
15468 //using enumerations here is dangerous
15469 //very easy to break old quests -DD
15470
2/2
✓ Branch 0 taken 1342 times.
✓ Branch 1 taken 220418 times.
221760 if(temp_mapscr->enemy[k]>=57) //old eGOHMA1
15471 {
15472 1342 temp_mapscr->enemy[k]+=5;
15473 1342 }
15474
2/2
✓ Branch 0 taken 220324 times.
✓ Branch 1 taken 94 times.
220418 else if(temp_mapscr->enemy[k]>=52) //old eGLEEOK2
15475 {
15476 94 temp_mapscr->enemy[k]+=1;
15477 94 }
15478 221760 }
15479
15480
2/2
✓ Branch 0 taken 6264160 times.
✓ Branch 1 taken 5285040 times.
11549200 if(version < 9)
15481 {
15482
2/2
✓ Branch 0 taken 5009135 times.
✓ Branch 1 taken 275905 times.
5285040 if(temp_mapscr->enemy[k]>0)
15483 {
15484 275905 temp_mapscr->enemy[k]+=10;
15485 275905 }
15486 5285040 }
15487 //don't read in any invalid data
15488
2/2
✓ Branch 0 taken 11548750 times.
✓ Branch 1 taken 450 times.
11549200 if ( ((unsigned)temp_mapscr->enemy[k]) > MAXGUYS )
15489 {
15490 450 al_trace("Tried to read an invalid enemy ID (%d) for tmpscr->enemy[%d]. This has been cleared to 0.\n", temp_mapscr->enemy[k], k);
15491 450 temp_mapscr->enemy[k] = 0;
15492 450 }
15493 11549200 }
15494
15495
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->pattern),f))
15496 {
15497 return qe_invalid;
15498 }
15499
15500
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->sidewarptype[0]),f))
15501 {
15502 return qe_invalid;
15503 }
15504
15505
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15506 {
15507
2/2
✓ Branch 0 taken 1879248 times.
✓ Branch 1 taken 626416 times.
2505664 for(int32_t i=1; i<4; i++)
15508 {
15509
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
15510 {
15511 return qe_invalid;
15512 }
15513 1879248 }
15514 626416 }
15515 else
15516 {
15517 528504 temp_mapscr->sidewarptype[1]=0;
15518 528504 temp_mapscr->sidewarptype[2]=0;
15519 528504 temp_mapscr->sidewarptype[3]=0;
15520 }
15521
15522
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version >= 15)
15523 {
15524
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
15525 {
15526 return qe_invalid;
15527 }
15528 626416 }
15529 else
15530 {
15531 528504 temp_mapscr->sidewarpoverlayflags=0;
15532 }
15533
15534
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->warparrivalx),f))
15535 {
15536 return qe_invalid;
15537 }
15538
15539
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->warparrivaly),f))
15540 {
15541 return qe_invalid;
15542 }
15543
15544
2/2
✓ Branch 0 taken 4619680 times.
✓ Branch 1 taken 1154920 times.
5774600 for(int32_t k=0; k<4; k++)
15545 {
15546
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4619680 times.
4619680 if(!p_getc(&(temp_mapscr->path[k]),f))
15547 {
15548 return qe_invalid;
15549 }
15550 4619680 }
15551
15552
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->sidewarpscr[0]),f))
15553 {
15554 return qe_invalid;
15555 }
15556
15557
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15558 {
15559
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 1879248 times.
2505664 for(int32_t i=1; i<4; i++)
15560 {
15561
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1879248 times.
1879248 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
15562 {
15563 return qe_invalid;
15564 }
15565 1879248 }
15566 626416 }
15567 else
15568 {
15569 528504 temp_mapscr->sidewarpscr[1]=0;
15570 528504 temp_mapscr->sidewarpscr[2]=0;
15571 528504 temp_mapscr->sidewarpscr[3]=0;
15572 }
15573
15574
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version <= 11)
15575 {
15576
1/2
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
528504 if(!p_getc(&(tempbyte),f))
15577 {
15578 return qe_invalid;
15579 }
15580
15581 528504 temp_mapscr->sidewarpdmap[0]=(word)tempbyte;
15582
15583
2/6
✓ Branch 0 taken 528504 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
528504 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15584 {
15585 for(int32_t i=1; i<4; i++)
15586 {
15587 if(!p_getc(&(tempbyte),f))
15588 {
15589 return qe_invalid;
15590 }
15591
15592 temp_mapscr->sidewarpdmap[i]=(word)tempbyte;
15593 }
15594 }
15595 else
15596 {
15597 528504 temp_mapscr->sidewarpdmap[1]=0;
15598 528504 temp_mapscr->sidewarpdmap[2]=0;
15599 528504 temp_mapscr->sidewarpdmap[3]=0;
15600 }
15601 528504 }
15602 else
15603 {
15604
2/2
✓ Branch 0 taken 2505664 times.
✓ Branch 1 taken 626416 times.
3132080 for(int32_t i=0; i<4; i++)
15605 {
15606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2505664 times.
2505664 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
15607 {
15608 return qe_invalid;
15609 }
15610 2505664 }
15611 }
15612
15613
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15614 {
15615
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
15616 {
15617 return qe_invalid;
15618 }
15619 626416 }
15620 528504 else temp_mapscr->sidewarpindex = 0;
15621
15622
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_igetw(&(temp_mapscr->undercombo),f))
15623 {
15624 return qe_invalid;
15625 }
15626
15627
2/2
✓ Branch 0 taken 1130024 times.
✓ Branch 1 taken 24896 times.
1154920 if(Header->zelda_version < 0x193)
15628 {
15629
1/2
✓ Branch 0 taken 24896 times.
✗ Branch 1 not taken.
24896 if(!p_getc(&(temp_mapscr->old_cpage),f))
15630 {
15631 return qe_invalid;
15632 }
15633 24896 }
15634
15635
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->undercset),f)) //recalculated for older quests
15636 {
15637 return qe_invalid;
15638 }
15639
15640
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_igetw(&(temp_mapscr->catchall),f))
15641 {
15642 return qe_invalid;
15643 }
15644
15645
1/2
✓ Branch 0 taken 1154920 times.
✗ Branch 1 not taken.
1154920 if(!p_getc(&(temp_mapscr->flags),f))
15646 {
15647 return qe_invalid;
15648 }
15649
15650
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->flags2),f))
15651 {
15652 return qe_invalid;
15653 }
15654
15655
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(!p_getc(&(temp_mapscr->flags3),f))
15656 {
15657 return qe_invalid;
15658 }
15659
15660
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>1)))
15661 //if (version>2)
15662 {
15663
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->flags4),f))
15664 {
15665 return qe_invalid;
15666 }
15667 626416 }
15668
15669
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>7)))
15670 {
15671
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->flags5),f))
15672 {
15673 return qe_invalid;
15674 }
15675
15676
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&(temp_mapscr->noreset),f))
15677 {
15678 return qe_invalid;
15679 }
15680
15681
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&(temp_mapscr->nocarry),f))
15682 {
15683 return qe_invalid;
15684 }
15685
15686
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(temp_mapscr->flags5&32)
15687 {
15688 temp_mapscr->flags5 &= ~32;
15689 temp_mapscr->noreset |= 48;
15690 }
15691
15692
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(version<8)
15693 {
15694 if(temp_mapscr->noreset&1)
15695 {
15696 temp_mapscr->noreset|=8192;
15697 }
15698
15699 if(temp_mapscr->nocarry&1)
15700 {
15701 temp_mapscr->nocarry|=8192;
15702 temp_mapscr->nocarry&=~1;
15703 }
15704 }
15705 626416 }
15706 else
15707 {
15708 528504 temp_mapscr->flags5 = 0;
15709 528504 temp_mapscr->noreset = 0;
15710 528504 temp_mapscr->nocarry = 0;
15711 }
15712
15713
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>9)))
15714 {
15715
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->flags6),f))
15716 {
15717 return qe_invalid;
15718 }
15719 626416 }
15720
15721
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version>5)
15722 {
15723
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->flags7),f))
15724 {
15725 return qe_invalid;
15726 }
15727
15728
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->flags8),f))
15729 {
15730 return qe_invalid;
15731 }
15732
15733
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->flags9),f))
15734 {
15735 return qe_invalid;
15736 }
15737
15738
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->flags10),f))
15739 {
15740 return qe_invalid;
15741 }
15742
15743
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->csensitive),f))
15744 {
15745 return qe_invalid;
15746 }
15747 626416 }
15748 else
15749 {
15750 528504 temp_mapscr->csensitive=1;
15751 }
15752
15753
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version<14) // August 2007: screen SFX added
15754 {
15755
2/2
✓ Branch 0 taken 527510 times.
✓ Branch 1 taken 994 times.
528504 if(temp_mapscr->flags&8) //fROAR
15756 {
15757 994 temp_mapscr->bosssfx=
15758
2/2
✓ Branch 0 taken 141 times.
✓ Branch 1 taken 853 times.
994 (temp_mapscr->flags3&2) ? WAV_DODONGO : // fDODONGO
15759 853 (temp_mapscr->flags2&32) ? WAV_VADER : // fVADER
15760 WAV_ROAR;
15761 994 }
15762
15763
2/2
✓ Branch 0 taken 170 times.
✓ Branch 1 taken 528334 times.
528504 if(temp_mapscr->flags&128) //fSEA
15764 {
15765 170 temp_mapscr->oceansfx=WAV_SEA;
15766 170 }
15767
15768 528504 temp_mapscr->secretsfx = (temp_mapscr->flags3&64) //fNOSECRETSOUND
15769 ? 0 : WAV_SECRET;
15770
15771 528504 temp_mapscr->flags3 &= ~66; //64|2
15772 528504 temp_mapscr->flags2 &= ~32;
15773 528504 temp_mapscr->flags &= ~136; // 128|8
15774 528504 }
15775 else
15776 {
15777
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->oceansfx),f))
15778 {
15779 return qe_invalid;
15780 }
15781
15782
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->bosssfx),f))
15783 {
15784 return qe_invalid;
15785 }
15786
15787
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->secretsfx),f))
15788 {
15789 return qe_invalid;
15790 }
15791 }
15792
15793
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version<15) // October 2007: another SFX
15794 {
15795 528504 temp_mapscr->holdupsfx=WAV_PICKUP;
15796 528504 }
15797 else
15798 {
15799
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->holdupsfx),f))
15800 {
15801 return qe_invalid;
15802 }
15803 }
15804
15805
15806
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
15807 {
15808
2/2
✓ Branch 0 taken 6796464 times.
✓ Branch 1 taken 1132744 times.
7929208 for(int32_t k=0; k<6; k++)
15809 {
15810
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6796464 times.
6796464 if(!p_getc(&(temp_mapscr->layermap[k]),f))
15811 {
15812 return qe_invalid;
15813 }
15814 6796464 }
15815
15816
2/2
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 6796464 times.
7929208 for(int32_t k=0; k<6; k++)
15817 {
15818
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6796464 times.
6796464 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
15819 {
15820 return qe_invalid;
15821 }
15822 6796464 }
15823 1132744 }
15824
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 22176 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
22176 else if((Header->zelda_version == 0x192)&&(Header->build>23)&&(Header->build<98))
15825 {
15826 if(!p_getc(&(temp_mapscr->layermap[2]),f))
15827 {
15828 return qe_invalid;
15829 }
15830
15831 if(!p_getc(&(temp_mapscr->layerscreen[2]),f))
15832 {
15833 return qe_invalid;
15834 }
15835
15836 if(!p_getc(&(temp_mapscr->layermap[4]),f))
15837 {
15838 return qe_invalid;
15839 }
15840
15841 if(!p_getc(&(temp_mapscr->layerscreen[4]),f))
15842
15843 {
15844 return qe_invalid;
15845 }
15846 }
15847
15848
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1152200 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1154920 if((Header->zelda_version == 0x192)&&(Header->build>149))
15849 {
15850
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15851 {
15852
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxsize
15853 {
15854 return qe_invalid;
15855 }
15856 16320 }
15857
15858
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15859 {
15860
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxspeed
15861 {
15862 return qe_invalid;
15863 }
15864 16320 }
15865
15866
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15867 {
15868
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerxdelay
15869 {
15870 return qe_invalid;
15871 }
15872 16320 }
15873
15874
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15875 {
15876
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerysize
15877 {
15878 return qe_invalid;
15879 }
15880 16320 }
15881
15882
2/2
✓ Branch 0 taken 16320 times.
✓ Branch 1 taken 2720 times.
19040 for(int32_t k=0; k<6; k++)
15883 {
15884
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layeryspeed
15885 {
15886 return qe_invalid;
15887 }
15888 16320 }
15889
15890
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 16320 times.
19040 for(int32_t k=0; k<6; k++)
15891 {
15892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16320 times.
16320 if(!p_getc(&tempbyte,f)) //layerydelay
15893 {
15894 return qe_invalid;
15895 }
15896 16320 }
15897 2720 }
15898
15899
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>149)))
15900 {
15901
2/2
✓ Branch 0 taken 6796464 times.
✓ Branch 1 taken 1132744 times.
7929208 for(int32_t k=0; k<6; k++)
15902 {
15903
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6796464 times.
6796464 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
15904 {
15905 return qe_invalid;
15906 }
15907 6796464 }
15908 1132744 }
15909
15910
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
15911 {
15912
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1132744 if((Header->zelda_version == 0x192)&&(Header->build>153))
15913 {
15914
1/2
✓ Branch 0 taken 2720 times.
✗ Branch 1 not taken.
2720 if(!p_getc(&padding,f))
15915 {
15916 return qe_invalid;
15917 }
15918 2720 }
15919
15920
1/2
✓ Branch 0 taken 1132744 times.
✗ Branch 1 not taken.
1132744 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
15921 {
15922 return qe_invalid;
15923 }
15924 1132744 }
15925
15926
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<24)))
15927 {
15928 22176 extras=15;
15929 22176 }
15930
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1132744 else if(((Header->zelda_version == 0x192)&&(Header->build<98)))
15931 {
15932 extras=11;
15933 }
15934
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
1132744 else if((Header->zelda_version == 0x192)&&(Header->build<150))
15935 {
15936 extras=32;
15937 }
15938
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1132744 else if((Header->zelda_version == 0x192)&&(Header->build<154))
15939 {
15940 extras=64;
15941 }
15942
2/2
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
1132744 else if(Header->zelda_version < 0x193)
15943 {
15944 2720 extras=62;
15945 2720 }
15946 else
15947
15948 {
15949 1130024 extras=0;
15950 }
15951
15952
2/2
✓ Branch 0 taken 501280 times.
✓ Branch 1 taken 1154920 times.
1656200 for(int32_t k=0; k<extras; k++)
15953 {
15954
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 501280 times.
501280 if(!p_getc(&tempbyte,f)) //extra[k]
15955 {
15956 return qe_invalid;
15957 }
15958 501280 }
15959
15960
3/6
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 528504 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x211)||((Header->zelda_version == 0x211)&&(Header->build>2)))
15961 //if (version>3)
15962 {
15963
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_getc(&(temp_mapscr->nextmap),f))
15964 {
15965 return qe_invalid;
15966 }
15967
15968
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->nextscr),f))
15969 {
15970 return qe_invalid;
15971 }
15972 626416 }
15973 else
15974 {
15975 528504 temp_mapscr->nextmap=0;
15976 528504 temp_mapscr->nextscr=0;
15977 }
15978
15979
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
15980 {
15981 22176 secretcombos=20;
15982 22176 }
15983
3/4
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1130024 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2720 times.
1132744 else if((Header->zelda_version == 0x192)&&(Header->build<154))
15984 {
15985 secretcombos=256;
15986 }
15987 else
15988 {
15989 1132744 secretcombos=128;
15990 }
15991
15992
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
15993 {
15994
2/2
✓ Branch 0 taken 443520 times.
✓ Branch 1 taken 22176 times.
465696 for(int32_t k=0; k<secretcombos; k++)
15995 {
15996
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(!p_getc(&tempbyte,f))
15997 {
15998 return qe_invalid;
15999 }
16000
16001
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 443520 times.
443520 if(k<128)
16002 {
16003 443520 temp_mapscr->secretcombo[k]=tempbyte;
16004 443520 }
16005 443520 }
16006 22176 }
16007 else
16008 {
16009
2/2
✓ Branch 0 taken 144991232 times.
✓ Branch 1 taken 1132744 times.
146123976 for(int32_t k=0; k<128; k++)
16010 {
16011
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144991232 times.
144991232 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16012 {
16013 return qe_invalid;
16014 }
16015
16016 144991232 }
16017 }
16018
16019
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>153)))
16020 {
16021
2/2
✓ Branch 0 taken 144991232 times.
✓ Branch 1 taken 1132744 times.
146123976 for(int32_t k=0; k<128; k++)
16022 {
16023
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144991232 times.
144991232 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16024 {
16025 return qe_invalid;
16026 }
16027 144991232 }
16028
16029
2/2
✓ Branch 0 taken 144991232 times.
✓ Branch 1 taken 1132744 times.
146123976 for(int32_t k=0; k<128; k++)
16030 {
16031
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 144991232 times.
144991232 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16032 {
16033 return qe_invalid;
16034 }
16035 144991232 }
16036 1132744 }
16037
16038
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1152200 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version == 0x192)&&(Header->build>97)&&(Header->build<154))
16039 {
16040 if(!p_getc(&padding,f))
16041 {
16042 return qe_invalid;
16043 }
16044 }
16045
16046
2/2
✓ Branch 0 taken 203265920 times.
✓ Branch 1 taken 1154920 times.
204420840 for(int32_t k=0; k<176; k++)
16047 {
16048
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 203265920 times.
203265920 if(!p_igetw(&(temp_mapscr->data[k]),f))
16049 {
16050 return qe_invalid;
16051 }
16052 203265920 }
16053
16054
4/6
✓ Branch 0 taken 2720 times.
✓ Branch 1 taken 1152200 times.
✓ Branch 2 taken 2720 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version == 0x192)&&(Header->build>20)&&(Header->build<24))
16055 {
16056 if(!p_getc(&padding,f))
16057 {
16058 return qe_invalid;
16059 }
16060
16061 if(!p_getc(&padding,f))
16062 {
16063 return qe_invalid;
16064 }
16065 }
16066
16067
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>20)))
16068 {
16069
2/2
✓ Branch 0 taken 199362944 times.
✓ Branch 1 taken 1132744 times.
200495688 for(int32_t k=0; k<176; k++)
16070 {
16071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199362944 times.
199362944 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16072 {
16073 return qe_invalid;
16074 }
16075
16076
3/4
✓ Branch 0 taken 478720 times.
✓ Branch 1 taken 198884224 times.
✓ Branch 2 taken 478720 times.
✗ Branch 3 not taken.
199362944 if((Header->zelda_version == 0x192)&&(Header->build<24))
16077 {
16078 if(!p_getc(&tempbyte,f))
16079 {
16080 return qe_invalid;
16081 }
16082
16083 if(!p_getc(&tempbyte,f))
16084 {
16085 return qe_invalid;
16086 }
16087
16088 if(!p_getc(&tempbyte,f))
16089 {
16090 return qe_invalid;
16091 }
16092 }
16093 199362944 }
16094 1132744 }
16095
16096
5/6
✓ Branch 0 taken 24896 times.
✓ Branch 1 taken 1130024 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 22176 times.
✓ Branch 4 taken 2720 times.
✗ Branch 5 not taken.
1154920 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>97)))
16097 {
16098
2/2
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 199362944 times.
200495688 for(int32_t k=0; k<176; k++)
16099 {
16100
16101
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 199362944 times.
199362944 if(!p_getc(&(temp_mapscr->cset[k]),f))
16102 {
16103 return qe_invalid;
16104 }
16105 199362944 }
16106 1132744 }
16107
16108
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16109 {
16110 22176 temp_mapscr->undercset=(temp_mapscr->undercombo>>8)&7;
16111 22176 temp_mapscr->undercombo=(temp_mapscr->undercombo&0xFF)+(temp_mapscr->old_cpage<<8);
16112 22176 }
16113
16114
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
16115 {
16116 22176 temp_mapscr->secretcombo[sSBOMB]=temp_mapscr->secretcombo[sBOMB];
16117 22176 temp_mapscr->secretcombo[sRCANDLE]=temp_mapscr->secretcombo[sBCANDLE];
16118 22176 temp_mapscr->secretcombo[sWANDFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16119 22176 temp_mapscr->secretcombo[sDIVINEFIRE]=temp_mapscr->secretcombo[sBCANDLE];
16120 22176 temp_mapscr->secretcombo[sSARROW]=temp_mapscr->secretcombo[sARROW];
16121 22176 temp_mapscr->secretcombo[sGARROW]=temp_mapscr->secretcombo[sARROW];
16122 22176 }
16123
16124
5/6
✓ Branch 0 taken 1132744 times.
✓ Branch 1 taken 22176 times.
✓ Branch 2 taken 2720 times.
✓ Branch 3 taken 1130024 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 2720 times.
1154920 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
16125 {
16126
2/2
✓ Branch 0 taken 3902976 times.
✓ Branch 1 taken 22176 times.
3925152 for(int32_t k=0; k<176; k++)
16127 {
16128
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version == 0x192)&&(Header->build>149))
16129 {
16130 if((Header->zelda_version == 0x192)&&(Header->build!=153))
16131 {
16132 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16133 }
16134 }
16135 else
16136 {
16137
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 3902976 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
3902976 if((Header->zelda_version < 0x192)||
16138 ((Header->zelda_version == 0x192)&&(Header->build<21)))
16139 {
16140 3902976 temp_mapscr->sflag[k]=(temp_mapscr->data[k]>>11);
16141 3902976 }
16142
16143 3902976 temp_mapscr->cset[k]=((temp_mapscr->data[k]>>8)&7);
16144 }
16145
16146 3902976 temp_mapscr->data[k]=(temp_mapscr->data[k]&0xFF)+(temp_mapscr->old_cpage<<8);
16147 3902976 }
16148 22176 }
16149
16150 /*if(version>12)
16151 {
16152 if(!p_getc(&(temp_mapscr->scrWidth),f))
16153 {
16154 return qe_invalid;
16155 }
16156 if(!p_getc(&(temp_mapscr->scrHeight),f))
16157 {
16158 return qe_invalid;
16159 }
16160 }*/
16161
16162
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version>4)
16163 {
16164
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16165 {
16166 return qe_invalid;
16167 }
16168 626416 }
16169 else
16170 {
16171 528504 temp_mapscr->screen_midi = -1;
16172 }
16173
16174
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version>=17)
16175 {
16176
1/2
✓ Branch 0 taken 626416 times.
✗ Branch 1 not taken.
626416 if(!p_getc(&(temp_mapscr->lens_layer),f))
16177 {
16178 return qe_invalid;
16179 }
16180 626416 }
16181 else
16182 {
16183 528504 temp_mapscr->lens_layer = llNORMAL;
16184 }
16185
16186
2/2
✓ Branch 0 taken 528504 times.
✓ Branch 1 taken 626416 times.
1154920 if(version>6)
16187 {
16188 dword bits;
16189
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 626416 times.
626416 if(!p_igetl(&bits,f))
16190 {
16191 return qe_invalid;
16192 }
16193
16194 int32_t m;
16195 float tempfloat;
16196 word tempw;
16197 626416 temp_mapscr->ffcCountMarkDirty();
16198
16199
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 20045312 times.
20671728 for(m=0; m<32; m++)
16200 {
16201 20045312 ffcdata& tempffc = temp_mapscr->ffcs[m];
16202 20045312 tempffc.clear();
16203
2/2
✓ Branch 0 taken 19785588 times.
✓ Branch 1 taken 259724 times.
20045312 if((bits>>m)&1)
16204 {
16205
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(!p_igetw(&tempw,f))
16206 {
16207 return qe_invalid;
16208 }
16209 259724 tempffc.data = tempw;
16210
16211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&(tempffc.cset),f))
16212 {
16213 return qe_invalid;
16214 }
16215
16216
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetw(&(tempffc.delay),f))
16217 {
16218 return qe_invalid;
16219 }
16220
16221
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(version < 9)
16222 {
16223 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16224 {
16225 return qe_invalid;
16226 }
16227
16228 tempffc.x=zslongToFix(int32_t(tempfloat*10000));
16229
16230 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16231 {
16232 return qe_invalid;
16233 }
16234
16235 tempffc.y=zslongToFix(int32_t(tempfloat*10000));
16236
16237 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16238 {
16239 return qe_invalid;
16240 }
16241
16242 tempffc.vx=zslongToFix(int32_t(tempfloat*10000));
16243
16244 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16245 {
16246 return qe_invalid;
16247 }
16248
16249 tempffc.vy=zslongToFix(int32_t(tempfloat*10000));
16250
16251 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16252 {
16253 return qe_invalid;
16254 }
16255
16256 tempffc.ax=zslongToFix(int32_t(tempfloat*10000));
16257
16258 if(!p_igetf_DO_NOT_USE(&tempfloat,f))
16259 {
16260 return qe_invalid;
16261 }
16262
16263 tempffc.ay=zslongToFix(int32_t(tempfloat*10000));
16264 }
16265 else
16266 {
16267
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.x),f))
16268 {
16269 return qe_invalid;
16270 }
16271
16272
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.y),f))
16273 {
16274 return qe_invalid;
16275 }
16276
16277
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(!p_igetzf(&(tempffc.vx),f))
16278 {
16279 return qe_invalid;
16280 }
16281
16282
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.vy),f))
16283 {
16284 return qe_invalid;
16285 }
16286
16287
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.ax),f))
16288 {
16289 return qe_invalid;
16290 }
16291
16292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetzf(&(tempffc.ay),f))
16293 {
16294 return qe_invalid;
16295 }
16296 }
16297
16298
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&(tempffc.link),f))
16299 {
16300 return qe_invalid;
16301 }
16302
16303
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(version>7)
16304 {
16305
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&tempbyte,f))
16306 {
16307 return qe_invalid;
16308 }
16309
16310 259724 tempffc.hit_width = (tempbyte&0x3F)+1;
16311 259724 tempffc.txsz = (tempbyte>>6)+1;
16312
16313
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&tempbyte,f))
16314 {
16315 return qe_invalid;
16316 }
16317
16318 259724 tempffc.hit_height = (tempbyte&0x3F)+1;
16319 259724 tempffc.tysz = (tempbyte>>6)+1;
16320
16321
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.flags),f))
16322 {
16323 return qe_invalid;
16324 }
16325 259724 }
16326 else
16327 {
16328 tempffc.hit_width=16;
16329 tempffc.hit_height=16;
16330 tempffc.txsz=1;
16331 tempffc.tysz=1;
16332 tempffc.flags=ffc_none;
16333 }
16334
16335 259724 tempffc.updateSolid();
16336
16337
16338
4/6
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 253720 times.
✓ Branch 3 taken 6004 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 253720 times.
259724 if(Header->zelda_version == 0x211 || (Header->zelda_version == 0x250 && Header->build<20))
16339 {
16340 tempffc.flags|=ffc_ignoreholdup;
16341 }
16342
16343
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(version>9)
16344 {
16345
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetw(&(tempffc.script),f))
16346 {
16347 return qe_invalid;
16348 }
16349 259724 }
16350 else
16351 {
16352 tempffc.script=0;
16353 }
16354
16355
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(version>10)
16356 {
16357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[0]),f))
16358 {
16359 return qe_invalid;
16360 }
16361
16362
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[1]),f))
16363 {
16364 return qe_invalid;
16365 }
16366
16367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[2]),f))
16368 {
16369 return qe_invalid;
16370 }
16371
16372
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[3]),f))
16373 {
16374 return qe_invalid;
16375 }
16376
16377
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[4]),f))
16378 {
16379 return qe_invalid;
16380 }
16381
16382
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[5]),f))
16383 {
16384 return qe_invalid;
16385 }
16386
16387
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[6]),f))
16388 {
16389 return qe_invalid;
16390 }
16391
16392
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_igetl(&(tempffc.initd[7]),f))
16393 {
16394 return qe_invalid;
16395 }
16396
16397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&(tempbyte),f))
16398 {
16399 return qe_invalid;
16400 }
16401
16402 259724 tempffc.inita[0]=tempbyte*10000;
16403
16404
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 259724 times.
259724 if(!p_getc(&(tempbyte),f))
16405 {
16406 return qe_invalid;
16407 }
16408
16409 259724 tempffc.inita[1]=tempbyte*10000;
16410 259724 }
16411 else
16412 {
16413 tempffc.inita[0] = 10000;
16414 tempffc.inita[1] = 10000;
16415 }
16416
16417
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16418 {
16419 tempffc.script = 0;
16420 for(int q = 0; q < 8; ++q)
16421 tempffc.initd[q] = 0;
16422 }
16423
1/2
✓ Branch 0 taken 259724 times.
✗ Branch 1 not taken.
259724 if(version <= 11)
16424 {
16425 fixffcs=true;
16426 }
16427 259724 }
16428 20045312 }
16429
2/2
✓ Branch 0 taken 60135936 times.
✓ Branch 1 taken 626416 times.
60762352 for(m = 32; m < MAXFFCS; ++m)
16430 {
16431 60135936 temp_mapscr->ffcs[m].clear();
16432 60135936 }
16433 626416 }
16434
16435 //add in the new whistle flags
16436
2/2
✓ Branch 0 taken 626416 times.
✓ Branch 1 taken 528504 times.
1154920 if(version<13)
16437 {
16438
2/2
✓ Branch 0 taken 124 times.
✓ Branch 1 taken 528380 times.
528504 if(temp_mapscr->flags & fWHISTLE)
16439 {
16440 124 temp_mapscr->flags7 |= (fWHISTLEPAL | fWHISTLEWATER);
16441 124 }
16442 528504 }
16443
16444 //2.55 starts here
16445
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1154920 if ( version >= 19 && Header->zelda_version > 0x253 )
16446 {
16447
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16448 {
16449
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16450 {
16451 return qe_invalid;
16452 }
16453 344080 }
16454
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16455 {
16456
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16457 {
16458 return qe_invalid;
16459 }
16460 344080 }
16461
2/2
✓ Branch 0 taken 344080 times.
✓ Branch 1 taken 34408 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16462 {
16463
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16464 {
16465 return qe_invalid;
16466 }
16467 344080 }
16468
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 344080 times.
378488 for ( int32_t q = 0; q < 10; q++ )
16469 {
16470
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 344080 times.
344080 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16471 {
16472 return qe_invalid;
16473 }
16474 344080 }
16475 34408 }
16476
3/4
✓ Branch 0 taken 1120512 times.
✓ Branch 1 taken 34408 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 1120512 times.
1154920 if ( version < 19 && Header->zelda_version > 0x253 )
16477 {
16478 for ( int32_t q = 0; q < 10; q++ )
16479 {
16480 temp_mapscr->npcstrings[q] = 0;
16481 temp_mapscr->new_items[q] = 0;
16482 temp_mapscr->new_item_x[q] = 0;
16483 temp_mapscr->new_item_y[q] = 0;
16484 }
16485 }
16486
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1154920 if ( version >= 20 && Header->zelda_version > 0x253 )
16487 {
16488
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_igetw(&(temp_mapscr->script),f))
16489 {
16490 return qe_invalid;
16491 }
16492
2/2
✓ Branch 0 taken 275264 times.
✓ Branch 1 taken 34408 times.
309672 for ( int32_t q = 0; q < 8; q++)
16493 {
16494
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 275264 times.
275264 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16495 {
16496 return qe_invalid;
16497 }
16498 275264 }
16499 34408 }
16500
2/2
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
1154920 if ( version < 20 )
16501 {
16502 1120512 temp_mapscr->script = 0;
16503
2/2
✓ Branch 0 taken 8964096 times.
✓ Branch 1 taken 1120512 times.
10084608 for ( int32_t q = 0; q < 8; q++) temp_mapscr->screeninitd[q] = 0;
16504 1120512 }
16505
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1154920 if ( version >= 21 && Header->zelda_version > 0x253 )
16506 {
16507
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->preloadscript),f))
16508 {
16509 return qe_invalid;
16510 }
16511 34408 }
16512
2/2
✓ Branch 0 taken 1120512 times.
✓ Branch 1 taken 34408 times.
1154920 if ( version < 21 )
16513 {
16514 1120512 temp_mapscr->preloadscript = 0;
16515 1120512 }
16516 //all builds with version > 20 need this. -Z
16517
16518
3/4
✓ Branch 0 taken 34408 times.
✓ Branch 1 taken 1120512 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 34408 times.
1154920 if ( version >= 22 && Header->zelda_version > 0x253 ) //26th June, 2019; Layer Visibility
16519 {
16520
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34408 times.
34408 if(!p_getc(&(temp_mapscr->hidelayers ),f))
16521 {
16522 return qe_invalid;
16523 }
16524
1/2
✓ Branch 0 taken 34408 times.
✗ Branch 1 not taken.
34408 if(!p_getc(&(temp_mapscr->hidescriptlayers ),f))
16525 {
16526 return qe_invalid;
16527 }
16528 34408 }
16529
2/2
✓ Branch 0 taken 1120512 times.
✓ Branch 1 taken 34408 times.
1154920 if ( version < 22 )
16530 {
16531 1120512 temp_mapscr->hidelayers = 0;
16532 1120512 temp_mapscr->hidescriptlayers = 0;
16533 1120512 }
16534
16535 //Dodongos in 2.10 used the boss roar, not the dodongo sound. -Z
16536 //May be any version before 2.11. -Z
16537 /* --not the roar, the HIT SFX
16538 if ( Header->zelda_version <= 0x210 )
16539 {
16540 if ( temp_mapscr->bosssfx == WAV_DODONGO )
16541 {
16542 temp_mapscr->bosssfx = WAV_ROAR;
16543 }
16544 }
16545 */
16546
2/2
✓ Branch 0 taken 4619680 times.
✓ Branch 1 taken 1154920 times.
5774600 for(int32_t k=0; k<4; k++)
16547 {
16548
1/2
✓ Branch 0 taken 4619680 times.
✗ Branch 1 not taken.
4619680 if(temp_mapscr->door[k] == dNONE)
16549 temp_mapscr->door[k] = dWALL;
16550 4619680 }
16551
16552 1154920 return 0;
16553 1154920 }
16554 1331856 int32_t readmapscreen(PACKFILE *f, zquestheader *Header, mapscr *temp_mapscr, word version, int scrind)
16555 {
16556
2/2
✓ Branch 0 taken 1154920 times.
✓ Branch 1 taken 176936 times.
1331856 if(version < 23)
16557 {
16558 1154920 auto ret = readmapscreen_old(f,Header,temp_mapscr,version);
16559
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1154920 times.
1154920 if(ret) return ret;
16560 1154920 }
16561 else
16562 {
16563
1/2
✓ Branch 0 taken 176936 times.
✗ Branch 1 not taken.
176936 if(!p_getc(&(temp_mapscr->valid),f))
16564 return qe_invalid;
16565
2/2
✓ Branch 0 taken 132202 times.
✓ Branch 1 taken 44734 times.
176936 if(!(temp_mapscr->valid & mVALID))
16566 {
16567 132202 int map = scrind/MAPSCRS;
16568 132202 int scr = scrind%MAPSCRS;
16569
4/6
✓ Branch 0 taken 124840 times.
✓ Branch 1 taken 7362 times.
✓ Branch 2 taken 124840 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 124840 times.
✗ Branch 5 not taken.
132202 if(version > 25 && scrind > -1 && (map*6+5) < map_autolayers.size())
16570 {
16571 //Empty screen, apply autolayers
16572
2/2
✓ Branch 0 taken 15156 times.
✓ Branch 1 taken 124840 times.
139996 for(int q = 0; q < 6; ++q)
16573 {
16574 15156 auto layermap = map_autolayers[map*6+q];
16575 15156 temp_mapscr->layermap[q] = layermap;
16576 15156 if(layermap)
16577 15156 temp_mapscr->layerscreen[q] = scr;
16578 15156 }
16579 124840 }
16580 132202 return 0;
16581 }
16582 uint32_t scr_has_flags;
16583
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(!p_igetl(&scr_has_flags,f))
16584 return qe_invalid;
16585
16586
2/2
✓ Branch 0 taken 10470 times.
✓ Branch 1 taken 34264 times.
44734 if(scr_has_flags & SCRHAS_ROOMDATA)
16587 {
16588
1/2
✓ Branch 0 taken 34264 times.
✗ Branch 1 not taken.
34264 if(!p_getc(&(temp_mapscr->guy),f))
16589 return qe_invalid;
16590
2/2
✓ Branch 0 taken 34144 times.
✓ Branch 1 taken 120 times.
34264 if(version > 26)
16591 {
16592
1/2
✓ Branch 0 taken 34144 times.
✗ Branch 1 not taken.
34144 if(!p_igetl(&(temp_mapscr->guytile),f))
16593 return qe_invalid;
16594
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 34144 times.
34144 if(!p_getc(&(temp_mapscr->guycs),f))
16595 return qe_invalid;
16596
1/2
✓ Branch 0 taken 34144 times.
✗ Branch 1 not taken.
34144 if(!p_igetw(&(temp_mapscr->roomflags),f))
16597 return qe_invalid;
16598 34144 }
16599 else
16600 {
16601 120 temp_mapscr->guytile = -1; //signal to use default guy values
16602
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
120 SETFLAG(temp_mapscr->roomflags,RFL_ALWAYS_GUY,temp_mapscr->guy==gFAIRY);
16603
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 120 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
120 SETFLAG(temp_mapscr->roomflags,RFL_GUYFIRES,temp_mapscr->guy!=gFAIRY || !get_qr(qr_NOFAIRYGUYFIRES));
16604 }
16605
1/2
✓ Branch 0 taken 34264 times.
✗ Branch 1 not taken.
34264 if(!p_igetw(&(temp_mapscr->str),f))
16606 return qe_invalid;
16607
1/2
✓ Branch 0 taken 34264 times.
✗ Branch 1 not taken.
34264 if(!p_getc(&(temp_mapscr->room),f))
16608 return qe_invalid;
16609
1/2
✓ Branch 0 taken 34264 times.
✗ Branch 1 not taken.
34264 if(!p_igetw(&(temp_mapscr->catchall),f))
16610 return qe_invalid;
16611 34264 }
16612
2/2
✓ Branch 0 taken 42936 times.
✓ Branch 1 taken 1798 times.
44734 if(scr_has_flags & SCRHAS_ITEM)
16613 {
16614
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1798 times.
1798 if(!p_getc(&(temp_mapscr->item),f))
16615 return qe_invalid;
16616
1/2
✓ Branch 0 taken 1798 times.
✗ Branch 1 not taken.
1798 if(!p_getc(&(temp_mapscr->hasitem),f))
16617 return qe_invalid;
16618
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1798 times.
1798 if(!p_getc(&(temp_mapscr->itemx),f))
16619 return qe_invalid;
16620
1/2
✓ Branch 0 taken 1798 times.
✗ Branch 1 not taken.
1798 if(!p_getc(&(temp_mapscr->itemy),f))
16621 return qe_invalid;
16622 1798 }
16623
2/2
✓ Branch 0 taken 36308 times.
✓ Branch 1 taken 8426 times.
44734 if(scr_has_flags & (SCRHAS_SWARP|SCRHAS_TWARP))
16624 {
16625
1/2
✓ Branch 0 taken 8426 times.
✗ Branch 1 not taken.
8426 if(!p_igetw(&temp_mapscr->warpreturnc,f))
16626 return qe_invalid;
16627 8426 }
16628
2/2
✓ Branch 0 taken 42640 times.
✓ Branch 1 taken 2094 times.
44734 if(scr_has_flags & SCRHAS_TWARP)
16629 {
16630
2/2
✓ Branch 0 taken 8376 times.
✓ Branch 1 taken 2094 times.
10470 for(int32_t i=0; i<4; i++)
16631 {
16632
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8376 times.
8376 if(!p_getc(&(temp_mapscr->tilewarptype[i]),f))
16633 return qe_invalid;
16634 8376 }
16635
2/2
✓ Branch 0 taken 8376 times.
✓ Branch 1 taken 2094 times.
10470 for(int32_t i=0; i<4; i++)
16636 {
16637
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8376 times.
8376 if(!p_igetw(&(temp_mapscr->tilewarpdmap[i]),f))
16638 return qe_invalid;
16639 8376 }
16640
2/2
✓ Branch 0 taken 8376 times.
✓ Branch 1 taken 2094 times.
10470 for(int32_t i=0; i<4; i++)
16641 {
16642
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8376 times.
8376 if(!p_getc(&(temp_mapscr->tilewarpscr[i]),f))
16643 return qe_invalid;
16644 8376 }
16645
1/2
✓ Branch 0 taken 2094 times.
✗ Branch 1 not taken.
2094 if(!p_getc(&(temp_mapscr->tilewarpoverlayflags),f))
16646 return qe_invalid;
16647 2094 }
16648
2/2
✓ Branch 0 taken 37970 times.
✓ Branch 1 taken 6764 times.
44734 if(scr_has_flags & SCRHAS_SWARP)
16649 {
16650
2/2
✓ Branch 0 taken 27056 times.
✓ Branch 1 taken 6764 times.
33820 for(int32_t i=0; i<4; i++)
16651 {
16652
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27056 times.
27056 if(!p_getc(&(temp_mapscr->sidewarptype[i]),f))
16653 return qe_invalid;
16654 27056 }
16655
2/2
✓ Branch 0 taken 27056 times.
✓ Branch 1 taken 6764 times.
33820 for(int32_t i=0; i<4; i++)
16656 {
16657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27056 times.
27056 if(!p_igetw(&(temp_mapscr->sidewarpdmap[i]),f))
16658 return qe_invalid;
16659 27056 }
16660
2/2
✓ Branch 0 taken 27056 times.
✓ Branch 1 taken 6764 times.
33820 for(int32_t i=0; i<4; i++)
16661 {
16662
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 27056 times.
27056 if(!p_getc(&(temp_mapscr->sidewarpscr[i]),f))
16663 return qe_invalid;
16664 27056 }
16665
1/2
✓ Branch 0 taken 6764 times.
✗ Branch 1 not taken.
6764 if(!p_getc(&(temp_mapscr->sidewarpoverlayflags),f))
16666 return qe_invalid;
16667
1/2
✓ Branch 0 taken 6764 times.
✗ Branch 1 not taken.
6764 if(!p_getc(&(temp_mapscr->sidewarpindex),f))
16668 return qe_invalid;
16669 6764 }
16670
2/2
✓ Branch 0 taken 39946 times.
✓ Branch 1 taken 4788 times.
44734 if(scr_has_flags & SCRHAS_WARPRET)
16671 {
16672
2/2
✓ Branch 0 taken 19152 times.
✓ Branch 1 taken 4788 times.
23940 for(int32_t i=0; i<4; i++)
16673 {
16674
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19152 times.
19152 if(!p_getc(&(temp_mapscr->warpreturnx[i]),f))
16675 return qe_invalid;
16676 19152 }
16677
2/2
✓ Branch 0 taken 19152 times.
✓ Branch 1 taken 4788 times.
23940 for(int32_t i=0; i<4; i++)
16678 {
16679
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 19152 times.
19152 if(!p_getc(&(temp_mapscr->warpreturny[i]),f))
16680 return qe_invalid;
16681 19152 }
16682
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4788 times.
4788 if(!p_getc(&(temp_mapscr->warparrivalx),f))
16683 return qe_invalid;
16684
1/2
✓ Branch 0 taken 4788 times.
✗ Branch 1 not taken.
4788 if(!p_getc(&(temp_mapscr->warparrivaly),f))
16685 return qe_invalid;
16686 4788 }
16687
2/2
✓ Branch 0 taken 34102 times.
✓ Branch 1 taken 10632 times.
44734 if(scr_has_flags & SCRHAS_LAYERS)
16688 {
16689
2/2
✓ Branch 0 taken 63792 times.
✓ Branch 1 taken 10632 times.
74424 for(int32_t k=0; k<6; k++)
16690 {
16691
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63792 times.
63792 if(!p_getc(&(temp_mapscr->layermap[k]),f))
16692 return qe_invalid;
16693 63792 }
16694
2/2
✓ Branch 0 taken 63792 times.
✓ Branch 1 taken 10632 times.
74424 for(int32_t k=0; k<6; k++)
16695 {
16696
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63792 times.
63792 if(!p_getc(&(temp_mapscr->layerscreen[k]),f))
16697 return qe_invalid;
16698 63792 }
16699
2/2
✓ Branch 0 taken 63792 times.
✓ Branch 1 taken 10632 times.
74424 for(int32_t k=0; k<6; k++)
16700 {
16701
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63792 times.
63792 if(!p_getc(&(temp_mapscr->layeropacity[k]),f))
16702 return qe_invalid;
16703 63792 }
16704
1/2
✓ Branch 0 taken 10632 times.
✗ Branch 1 not taken.
10632 if(!p_getc(&(temp_mapscr->hidelayers),f))
16705 return qe_invalid;
16706
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10632 times.
10632 if(!p_getc(&(temp_mapscr->hidescriptlayers),f))
16707 return qe_invalid;
16708 10632 }
16709
2/2
✓ Branch 0 taken 44732 times.
✓ Branch 1 taken 2 times.
44734 if(scr_has_flags & SCRHAS_MAZE)
16710 {
16711
2/2
✓ Branch 0 taken 8 times.
✓ Branch 1 taken 2 times.
10 for(int32_t k=0; k<4; k++)
16712 {
16713
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8 times.
8 if(!p_getc(&(temp_mapscr->path[k]),f))
16714 return qe_invalid;
16715 8 }
16716
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2 times.
2 if(!p_getc(&(temp_mapscr->exitdir),f))
16717 return qe_invalid;
16718 2 }
16719
2/2
✓ Branch 0 taken 20128 times.
✓ Branch 1 taken 24606 times.
44734 if(scr_has_flags & SCRHAS_D_S_U)
16720 {
16721
1/2
✓ Branch 0 taken 20128 times.
✗ Branch 1 not taken.
20128 if(!p_igetw(&(temp_mapscr->door_combo_set),f))
16722 return qe_invalid;
16723
2/2
✓ Branch 0 taken 80512 times.
✓ Branch 1 taken 20128 times.
100640 for(int32_t k=0; k<4; k++)
16724 {
16725
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 80512 times.
80512 if(!p_getc(&(temp_mapscr->door[k]),f))
16726 return qe_invalid;
16727
3/4
✓ Branch 0 taken 376 times.
✓ Branch 1 taken 80136 times.
✓ Branch 2 taken 376 times.
✗ Branch 3 not taken.
80512 if(version < 29 && temp_mapscr->door[k] == dNONE)
16728 temp_mapscr->door[k] = dWALL;
16729 80512 }
16730
16731
1/2
✓ Branch 0 taken 20128 times.
✗ Branch 1 not taken.
20128 if(!p_getc(&(temp_mapscr->stairx),f))
16732 return qe_invalid;
16733
16734
1/2
✓ Branch 0 taken 20128 times.
✗ Branch 1 not taken.
20128 if(!p_getc(&(temp_mapscr->stairy),f))
16735 return qe_invalid;
16736
1/2
✓ Branch 0 taken 20128 times.
✗ Branch 1 not taken.
20128 if(!p_igetw(&(temp_mapscr->undercombo),f))
16737 return qe_invalid;
16738
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 20128 times.
20128 if(!p_getc(&(temp_mapscr->undercset),f))
16739 return qe_invalid;
16740 20128 }
16741
2/2
✓ Branch 0 taken 14110 times.
✓ Branch 1 taken 10496 times.
24606 else if(version < 29)
16742 {
16743
2/2
✓ Branch 0 taken 41984 times.
✓ Branch 1 taken 10496 times.
52480 for(int k = 0; k < 4; ++k)
16744 41984 temp_mapscr->door[k] = dWALL;
16745 10496 }
16746
2/2
✓ Branch 0 taken 39001 times.
✓ Branch 1 taken 5733 times.
44734 if(scr_has_flags & SCRHAS_FLAGS)
16747 {
16748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5733 times.
5733 if(!p_getc(&(temp_mapscr->flags),f))
16749 return qe_invalid;
16750
1/2
✓ Branch 0 taken 5733 times.
✗ Branch 1 not taken.
5733 if(!p_getc(&(temp_mapscr->flags2),f))
16751 return qe_invalid;
16752
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5733 times.
5733 if(!p_getc(&(temp_mapscr->flags3),f))
16753 return qe_invalid;
16754
1/2
✓ Branch 0 taken 5733 times.
✗ Branch 1 not taken.
5733 if(!p_getc(&(temp_mapscr->flags4),f))
16755 return qe_invalid;
16756
1/2
✓ Branch 0 taken 5733 times.
✗ Branch 1 not taken.
5733 if(!p_getc(&(temp_mapscr->flags5),f))
16757 return qe_invalid;
16758
1/2
✓ Branch 0 taken 5733 times.
✗ Branch 1 not taken.
5733 if(!p_getc(&(temp_mapscr->flags6),f))
16759 return qe_invalid;
16760
1/2
✓ Branch 0 taken 5733 times.
✗ Branch 1 not taken.
5733 if(!p_getc(&(temp_mapscr->flags7),f))
16761 return qe_invalid;
16762
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5733 times.
5733 if(!p_getc(&(temp_mapscr->flags8),f))
16763 return qe_invalid;
16764
1/2
✓ Branch 0 taken 5733 times.
✗ Branch 1 not taken.
5733 if(!p_getc(&(temp_mapscr->flags9),f))
16765 return qe_invalid;
16766
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5733 times.
5733 if(!p_getc(&(temp_mapscr->flags10),f))
16767 return qe_invalid;
16768
1/2
✓ Branch 0 taken 5733 times.
✗ Branch 1 not taken.
5733 if(!p_getc(&(temp_mapscr->enemyflags),f))
16769 return qe_invalid;
16770 5733 }
16771
2/2
✓ Branch 0 taken 40218 times.
✓ Branch 1 taken 4516 times.
44734 if(scr_has_flags & SCRHAS_ENEMY)
16772 {
16773
2/2
✓ Branch 0 taken 45160 times.
✓ Branch 1 taken 4516 times.
49676 for(int32_t k=0; k<10; k++)
16774 {
16775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 45160 times.
45160 if(!p_igetw(&(temp_mapscr->enemy[k]),f))
16776 return qe_invalid;
16777
1/2
✓ Branch 0 taken 45160 times.
✗ Branch 1 not taken.
45160 if (unsigned(temp_mapscr->enemy[k]) > MAXGUYS)
16778 temp_mapscr->enemy[k] = 0;
16779 45160 }
16780
1/2
✓ Branch 0 taken 4516 times.
✗ Branch 1 not taken.
4516 if(!p_getc(&(temp_mapscr->pattern),f))
16781 return qe_invalid;
16782 4516 }
16783
2/2
✓ Branch 0 taken 44416 times.
✓ Branch 1 taken 318 times.
44734 if(scr_has_flags & SCRHAS_CARRY)
16784 {
16785
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 318 times.
318 if(!p_igetw(&(temp_mapscr->noreset),f))
16786 return qe_invalid;
16787
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_igetw(&(temp_mapscr->nocarry),f))
16788 return qe_invalid;
16789
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->nextmap),f))
16790 return qe_invalid;
16791
1/2
✓ Branch 0 taken 318 times.
✗ Branch 1 not taken.
318 if(!p_getc(&(temp_mapscr->nextscr),f))
16792 return qe_invalid;
16793 318 }
16794
2/2
✓ Branch 0 taken 44269 times.
✓ Branch 1 taken 465 times.
44734 if(scr_has_flags & SCRHAS_SCRIPT)
16795 {
16796
1/2
✓ Branch 0 taken 465 times.
✗ Branch 1 not taken.
465 if(!p_igetw(&(temp_mapscr->script),f))
16797 return qe_invalid;
16798
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 465 times.
465 if(!p_getc(&(temp_mapscr->preloadscript),f))
16799 return qe_invalid;
16800
2/2
✓ Branch 0 taken 3720 times.
✓ Branch 1 taken 465 times.
4185 for ( int32_t q = 0; q < 8; q++ )
16801 {
16802
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3720 times.
3720 if(!p_igetl(&(temp_mapscr->screeninitd[q]),f))
16803 return qe_invalid;
16804 3720 }
16805 465 }
16806
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(scr_has_flags & SCRHAS_UNUSED)
16807 {
16808 for ( int32_t q = 0; q < 10; q++ )
16809 {
16810 if(!p_igetl(&(temp_mapscr->npcstrings[q]),f))
16811 return qe_invalid;
16812 }
16813 for ( int32_t q = 0; q < 10; q++ )
16814 {
16815 if(!p_igetw(&(temp_mapscr->new_items[q]),f))
16816 return qe_invalid;
16817 }
16818 for ( int32_t q = 0; q < 10; q++ )
16819 {
16820 if(!p_igetw(&(temp_mapscr->new_item_x[q]),f))
16821 return qe_invalid;
16822 }
16823 for ( int32_t q = 0; q < 10; q++ )
16824 {
16825 if(!p_igetw(&(temp_mapscr->new_item_y[q]),f))
16826 return qe_invalid;
16827 }
16828 }
16829
2/2
✓ Branch 0 taken 39670 times.
✓ Branch 1 taken 5064 times.
44734 if(scr_has_flags & SCRHAS_SECRETS)
16830 {
16831
2/2
✓ Branch 0 taken 648192 times.
✓ Branch 1 taken 5064 times.
653256 for(int32_t k=0; k<128; k++)
16832 {
16833
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 648192 times.
648192 if(!p_igetw(&(temp_mapscr->secretcombo[k]),f))
16834 return qe_invalid;
16835 648192 }
16836
2/2
✓ Branch 0 taken 648192 times.
✓ Branch 1 taken 5064 times.
653256 for(int32_t k=0; k<128; k++)
16837 {
16838
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 648192 times.
648192 if(!p_getc(&(temp_mapscr->secretcset[k]),f))
16839 return qe_invalid;
16840 648192 }
16841
2/2
✓ Branch 0 taken 648192 times.
✓ Branch 1 taken 5064 times.
653256 for(int32_t k=0; k<128; k++)
16842 {
16843
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 648192 times.
648192 if(!p_getc(&(temp_mapscr->secretflag[k]),f))
16844 return qe_invalid;
16845 648192 }
16846 5064 }
16847
2/2
✓ Branch 0 taken 13165 times.
✓ Branch 1 taken 31569 times.
44734 if(scr_has_flags & SCRHAS_COMBOFLAG)
16848 {
16849
2/2
✓ Branch 0 taken 5556144 times.
✓ Branch 1 taken 31569 times.
5587713 for(int32_t k=0; k<176; ++k)
16850 {
16851
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5556144 times.
5556144 if(!p_igetw(&(temp_mapscr->data[k]),f))
16852 return qe_invalid;
16853 5556144 }
16854
2/2
✓ Branch 0 taken 5556144 times.
✓ Branch 1 taken 31569 times.
5587713 for(int32_t k=0; k<176; ++k)
16855 {
16856
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5556144 times.
5556144 if(!p_getc(&(temp_mapscr->sflag[k]),f))
16857 return qe_invalid;
16858 5556144 }
16859
2/2
✓ Branch 0 taken 5556144 times.
✓ Branch 1 taken 31569 times.
5587713 for(int32_t k=0; k<176; ++k)
16860 {
16861
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 5556144 times.
5556144 if(!p_getc(&(temp_mapscr->cset[k]),f))
16862 return qe_invalid;
16863 5556144 }
16864 31569 }
16865
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(scr_has_flags & SCRHAS_MISC)
16866 {
16867
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(!p_igetw(&(temp_mapscr->color),f))
16868 return qe_invalid;
16869
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(!p_getc(&(temp_mapscr->csensitive),f))
16870 return qe_invalid;
16871
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(!p_getc(&(temp_mapscr->oceansfx),f))
16872 return qe_invalid;
16873
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(!p_getc(&(temp_mapscr->bosssfx),f))
16874 return qe_invalid;
16875
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44734 times.
44734 if(!p_getc(&(temp_mapscr->secretsfx),f))
16876 return qe_invalid;
16877
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(!p_getc(&(temp_mapscr->holdupsfx),f))
16878 return qe_invalid;
16879
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(!p_igetw(&(temp_mapscr->timedwarptics),f))
16880 return qe_invalid;
16881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44734 times.
44734 if(!p_igetw(&(temp_mapscr->screen_midi),f))
16882 return qe_invalid;
16883
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(!p_getc(&(temp_mapscr->lens_layer),f))
16884 return qe_invalid;
16885
2/2
✓ Branch 0 taken 10590 times.
✓ Branch 1 taken 34144 times.
44734 if(version > 27)
16886 {
16887
1/2
✓ Branch 0 taken 34144 times.
✗ Branch 1 not taken.
34144 if(!p_getc(&(temp_mapscr->lens_show),f))
16888 return qe_invalid;
16889
1/2
✓ Branch 0 taken 34144 times.
✗ Branch 1 not taken.
34144 if(!p_getc(&(temp_mapscr->lens_hide),f))
16890 return qe_invalid;
16891 34144 }
16892 44734 }
16893 else
16894 {
16895 temp_mapscr->screen_midi = -1;
16896 temp_mapscr->csensitive = 1;
16897 }
16898 //FFC
16899 44734 bool old_ff = version < 25;
16900 44734 dword bits = 0;
16901 44734 word numffc = 32;
16902
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 44734 times.
44734 if(old_ff)
16903 {
16904 if(!p_igetl(&bits,f))
16905 return qe_invalid;
16906 }
16907 else
16908 {
16909
1/2
✓ Branch 0 taken 44734 times.
✗ Branch 1 not taken.
44734 if(!p_igetw(&numffc,f))
16910 return qe_invalid;
16911 }
16912 byte tempbyte;
16913 word tempw;
16914
4/6
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 44458 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 276 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 276 times.
44734 static ffcdata nil_ffc;
16915 44734 temp_mapscr->ffcCountMarkDirty();
16916
2/2
✓ Branch 0 taken 77609 times.
✓ Branch 1 taken 44734 times.
122343 for(word m = 0; m < numffc; ++m)
16917 {
16918
1/2
✓ Branch 0 taken 77609 times.
✗ Branch 1 not taken.
77609 ffcdata& tempffc = (m < MAXFFCS)
16919 77609 ? temp_mapscr->ffcs[m]
16920 : nil_ffc; //sanity
16921 77609 tempffc.clear();
16922
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 77609 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
77609 if(old_ff && !(bits & (1<<m))) continue;
16923
16924
1/2
✓ Branch 0 taken 77609 times.
✗ Branch 1 not taken.
77609 if(!p_igetw(&tempw,f))
16925 return qe_invalid;
16926
3/4
✓ Branch 0 taken 77609 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 12625 times.
✓ Branch 3 taken 64984 times.
77609 if(!old_ff && !tempw) //empty ffc, nothing more to load
16927 64984 continue;
16928 12625 tempffc.data = tempw;
16929
16930
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_getc(&(tempffc.cset),f))
16931 return qe_invalid;
16932
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_igetw(&(tempffc.delay),f))
16933 return qe_invalid;
16934
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_igetzf(&(tempffc.x),f))
16935 return qe_invalid;
16936
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_igetzf(&(tempffc.y),f))
16937 return qe_invalid;
16938
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_igetzf(&(tempffc.vx),f))
16939 return qe_invalid;
16940
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_igetzf(&(tempffc.vy),f))
16941 return qe_invalid;
16942
1/2
✓ Branch 0 taken 12625 times.
✗ Branch 1 not taken.
12625 if(!p_igetzf(&(tempffc.ax),f))
16943 return qe_invalid;
16944
1/2
✓ Branch 0 taken 12625 times.
✗ Branch 1 not taken.
12625 if(!p_igetzf(&(tempffc.ay),f))
16945 return qe_invalid;
16946
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_getc(&(tempffc.link),f))
16947 return qe_invalid;
16948
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(version < 24)
16949 {
16950 if(!p_getc(&tempbyte,f))
16951 return qe_invalid;
16952 tempffc.hit_width = (tempbyte&0x3F)+1;
16953 tempffc.txsz = (tempbyte>>6)+1;
16954 if(!p_getc(&tempbyte,f))
16955 return qe_invalid;
16956 tempffc.hit_height = (tempbyte&0x3F)+1;
16957 tempffc.tysz = (tempbyte>>6)+1;
16958 }
16959 else
16960 {
16961
1/2
✓ Branch 0 taken 12625 times.
✗ Branch 1 not taken.
12625 if(!p_igetl(&(tempffc.hit_width),f))
16962 return qe_invalid;
16963
1/2
✓ Branch 0 taken 12625 times.
✗ Branch 1 not taken.
12625 if(!p_igetl(&(tempffc.hit_height),f))
16964 return qe_invalid;
16965
1/2
✓ Branch 0 taken 12625 times.
✗ Branch 1 not taken.
12625 if(!p_getc(&(tempffc.txsz),f))
16966 return qe_invalid;
16967
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_getc(&(tempffc.tysz),f))
16968 return qe_invalid;
16969 }
16970
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_igetl(&(tempffc.flags),f))
16971 return qe_invalid;
16972 12625 tempffc.updateSolid();
16973
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_igetw(&(tempffc.script),f))
16974 return qe_invalid;
16975
2/2
✓ Branch 0 taken 101000 times.
✓ Branch 1 taken 12625 times.
113625 for(auto q = 0; q < 8; ++q)
16976 {
16977
1/2
✓ Branch 0 taken 101000 times.
✗ Branch 1 not taken.
101000 if(!p_igetl(&(tempffc.initd[q]),f))
16978 return qe_invalid;
16979 101000 }
16980
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12625 times.
12625 if(!p_getc(&(tempbyte),f))
16981 return qe_invalid;
16982 12625 tempffc.inita[0]=tempbyte*10000;
16983
16984
1/2
✓ Branch 0 taken 12625 times.
✗ Branch 1 not taken.
12625 if(!p_getc(&(tempbyte),f))
16985 return qe_invalid;
16986 12625 tempffc.inita[1]=tempbyte*10000;
16987
16988
1/2
✓ Branch 0 taken 12625 times.
✗ Branch 1 not taken.
12625 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
16989 {
16990 tempffc.script = 0;
16991 for(int q = 0; q < 8; ++q)
16992 tempffc.initd[q] = 0;
16993 }
16994 12625 }
16995
2/2
✓ Branch 0 taken 5648343 times.
✓ Branch 1 taken 44734 times.
5693077 for(word m = numffc; m < MAXFFCS; ++m)
16996 {
16997 5648343 temp_mapscr->ffcs[m].clear();
16998 5648343 }
16999 //END FFC
17000
2/2
✓ Branch 0 taken 35846 times.
✓ Branch 1 taken 8888 times.
44734 if(version > 29)
17001
1/2
✓ Branch 0 taken 8888 times.
✗ Branch 1 not taken.
8888 if(!p_getlstr(&temp_mapscr->usr_notes, f))
17002 return qe_invalid;
17003 }
17004 1199654 return 0;
17005 1331856 }
17006
17007
17008 695 int32_t readmaps(PACKFILE *f, zquestheader *Header)
17009 {
17010
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_maps);
17011 695 int32_t scr=0;
17012
17013 695 word version=0;
17014 dword dummy;
17015 int32_t screens_to_read;
17016
17017 695 mapscr temp_mapscr;
17018 word temp_map_count;
17019 dword section_size;
17020
17021
5/6
✓ Branch 0 taken 677 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 671 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
695 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17022 {
17023 18 screens_to_read=MAPSCRS192b136;
17024 18 }
17025 else
17026 {
17027 677 screens_to_read=MAPSCRS;
17028 }
17029
17030
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 if(Header->zelda_version > 0x192)
17031 {
17032 //section version info
17033
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&version,f))
17034 {
17035 return qe_invalid;
17036 }
17037
17038 671 FFCore.quest_format[vMaps] = version;
17039
17040
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&dummy,f))
17041 {
17042 return qe_invalid;
17043 }
17044
17045 //section size
17046
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetl(&section_size,f))
17047 {
17048 return qe_invalid;
17049 }
17050
17051 //finally... section data
17052
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&temp_map_count,f))
17053 {
17054 return 5;
17055 }
17056 671 }
17057 else
17058 {
17059 24 temp_map_count=map_count;
17060 }
17061
17062
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 if (temp_map_count > MAXMAPS)
17063 {
17064 return qe_invalid;
17065 }
17066
17067
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 1 times.
695 if (!should_skip)
17068 {
17069 694 const int32_t _mapsSize = MAPSCRS*temp_map_count;
17070
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 TheMaps.resize(_mapsSize);
17071 694 map_autolayers.clear();
17072
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 map_autolayers.resize(temp_map_count*6);
17073
2/2
✓ Branch 0 taken 1336472 times.
✓ Branch 1 taken 694 times.
1337166 for(int32_t i(0); i<_mapsSize; i++)
17074
1/2
✓ Branch 0 taken 1336472 times.
✗ Branch 1 not taken.
1336472 TheMaps[i].zero_memory();
17075 694 }
17076
17077
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 temp_mapscr.zero_memory();
17078
17079
4/4
✓ Branch 0 taken 695 times.
✓ Branch 1 taken 9829 times.
✓ Branch 2 taken 695 times.
✓ Branch 3 taken 9829 times.
10524 for(int32_t i=0; i<temp_map_count && i<MAXMAPS; i++)
17080 {
17081 9829 byte valid=1;
17082
2/2
✓ Branch 0 taken 1332 times.
✓ Branch 1 taken 8497 times.
9829 if(version > 22)
17083 {
17084
2/4
✓ Branch 0 taken 1332 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1332 times.
✗ Branch 3 not taken.
1332 if(!p_getc(&valid,f))
17085 return qe_invalid;
17086 1332 }
17087
4/4
✓ Branch 0 taken 9798 times.
✓ Branch 1 taken 31 times.
✓ Branch 2 taken 8629 times.
✓ Branch 3 taken 1169 times.
9829 if(valid && version > 25)
17088 {
17089
2/2
✓ Branch 0 taken 7014 times.
✓ Branch 1 taken 1169 times.
8183 for(int q = 0; q < 6; ++q)
17090 {
17091
2/4
✓ Branch 0 taken 7014 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7014 times.
✗ Branch 3 not taken.
7014 if(!p_igetw(&map_autolayers[i*6+q],f))
17092 return qe_invalid;
17093 7014 }
17094 1169 }
17095
2/2
✓ Branch 0 taken 1336072 times.
✓ Branch 1 taken 9829 times.
1345901 for(int32_t j=0; j<screens_to_read; j++)
17096 {
17097 1336072 scr=i*MAPSCRS+j;
17098
1/2
✓ Branch 0 taken 1336072 times.
✗ Branch 1 not taken.
1336072 clear_screen(&temp_mapscr);
17099
2/2
✓ Branch 0 taken 1331856 times.
✓ Branch 1 taken 4216 times.
1336072 if(valid)
17100
1/2
✓ Branch 0 taken 1331856 times.
✗ Branch 1 not taken.
1331856 readmapscreen(f, Header, &temp_mapscr, version, scr);
17101
17102
2/2
✓ Branch 0 taken 1335800 times.
✓ Branch 1 taken 272 times.
1336072 if (!should_skip)
17103
1/2
✓ Branch 0 taken 1335800 times.
✗ Branch 1 not taken.
1335800 TheMaps[scr] = temp_mapscr;
17104 1336072 }
17105
17106
2/2
✓ Branch 0 taken 9827 times.
✓ Branch 1 taken 2 times.
9829 if (should_skip)
17107 2 continue;
17108
17109
5/6
✓ Branch 0 taken 9659 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9641 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
9827 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<137)))
17110 {
17111 168 int32_t index = (i*MAPSCRS+132);
17112
17113
1/2
✓ Branch 0 taken 168 times.
✗ Branch 1 not taken.
168 TheMaps[index]=TheMaps[index-1];
17114
17115 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].data, TheMaps[i*MAPSCRS+131].data);
17116 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].sflag, TheMaps[i*MAPSCRS+131].sflag);
17117 168 MEMCPY_ARR(TheMaps[i*MAPSCRS+132].cset, TheMaps[i*MAPSCRS+131].cset);
17118
17119
2/2
✓ Branch 0 taken 504 times.
✓ Branch 1 taken 168 times.
672 for(int32_t j=133; j<MAPSCRS; j++)
17120 {
17121 504 scr=i*MAPSCRS+j;
17122
17123
1/2
✓ Branch 0 taken 504 times.
✗ Branch 1 not taken.
504 TheMaps[scr].zero_memory();
17124 504 TheMaps[scr].valid = mVERSION;
17125 504 TheMaps[scr].screen_midi = -1;
17126 504 TheMaps[scr].csensitive = 1;
17127 504 }
17128 168 }
17129
17130
5/6
✓ Branch 0 taken 9659 times.
✓ Branch 1 taken 168 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 9641 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 18 times.
9827 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<154)))
17131 {
17132
2/2
✓ Branch 0 taken 22848 times.
✓ Branch 1 taken 168 times.
23016 for(int32_t j=0; j<MAPSCRS; j++)
17133 {
17134 22848 scr=i*MAPSCRS+j;
17135 22848 TheMaps[scr].door_combo_set=MakeDoors(i, j);
17136
17137
2/2
✓ Branch 0 taken 2924544 times.
✓ Branch 1 taken 22848 times.
2947392 for(int32_t k=0; k<128; k++)
17138 {
17139
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretcset[k]=tcmbcset2(i, TheMaps[scr].secretcombo[k]);
17140
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretflag[k]=tcmbflag2(i, TheMaps[scr].secretcombo[k]);
17141
1/2
✓ Branch 0 taken 2924544 times.
✗ Branch 1 not taken.
2924544 TheMaps[scr].secretcombo[k]=tcmbdat2(i, j, TheMaps[scr].secretcombo[k]);
17142 2924544 }
17143 22848 }
17144 168 }
17145 9827 }
17146 695 map_count = temp_map_count;
17147
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 clear_screen(&temp_mapscr);
17148 695 return 0;
17149 695 }
17150
17151
17152 9852016 void update_combo(newcombo& cmb, word section_version)
17153 {
17154
2/2
✓ Branch 0 taken 2277285 times.
✓ Branch 1 taken 7574731 times.
9852016 if(section_version < 40)
17155 {
17156
3/3
✓ Branch 0 taken 5025 times.
✓ Branch 1 taken 44980 times.
✓ Branch 2 taken 7524726 times.
7574731 switch(cmb.type)
17157 {
17158 case cWATER: case cSHALLOWWATER:
17159 44980 cmb.attribytes[6] = iwRipples;
17160 44980 break;
17161 case cTALLGRASS: case cTALLGRASSNEXT: case cTALLGRASSTOUCHY:
17162 5025 cmb.attribytes[6] = iwTallGrass;
17163 5025 break;
17164 }
17165 7574731 }
17166 9852016 }
17167 277 int32_t readcombos_old(word section_version, PACKFILE *f, zquestheader *, word version, word build, word start_combo, word max_combos)
17168 {
17169
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 24 times.
277 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17170
17171
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 276 times.
277 if (!should_skip)
17172 {
17173 276 reset_combo_animations();
17174 276 reset_combo_animations2();
17175 276 init_combo_classes();
17176 276 }
17177
17178 // combos
17179 277 word combos_used=0;
17180 int32_t dummy;
17181 byte padding;
17182 277 newcombo temp_combo;
17183 //word section_cversion=0;
17184
17185
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 276 times.
277 if (!should_skip)
17186
2/2
✓ Branch 0 taken 18017280 times.
✓ Branch 1 taken 276 times.
18017556 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
17187
1/2
✓ Branch 0 taken 18017280 times.
✗ Branch 1 not taken.
18017556 combobuf[q].clear();
17188
17189 // if(version > 0x192)
17190 // {
17191 // //section version info
17192 // if(!p_igetw(&section_version,f))
17193 // {
17194 // return qe_invalid;
17195 // }
17196
17197 // FFCore.quest_format[vCombos] = section_version;
17198
17199 // if(!p_igetw(&section_cversion,f))
17200 // {
17201 // return qe_invalid;
17202 // }
17203
17204 // //section size
17205 // if(!p_igetl(&dummy,f))
17206 // {
17207 // return qe_invalid;
17208 // }
17209 // }
17210
17211
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if(version < 0x174)
17212 {
17213 combos_used=1024;
17214 }
17215
2/2
✓ Branch 0 taken 259 times.
✓ Branch 1 taken 18 times.
277 else if(version < 0x191)
17216 {
17217 18 combos_used=2048;
17218 18 }
17219 else
17220 {
17221
2/4
✓ Branch 0 taken 259 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 259 times.
✗ Branch 3 not taken.
259 if(!p_igetw(&combos_used,f))
17222 {
17223 return qe_invalid;
17224 }
17225 }
17226
17227 //finally... section data
17228
2/2
✓ Branch 0 taken 7439715 times.
✓ Branch 1 taken 277 times.
7439992 for(int32_t i=0; i<combos_used; i++)
17229 {
17230
1/2
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
7439715 temp_combo.clear();
17231
17232
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if ( section_version >= 11 )
17233 {
17234
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.tile,f))
17235 {
17236 return qe_invalid;
17237 }
17238 202968 }
17239 else
17240 {
17241
2/4
✓ Branch 0 taken 7236747 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7236747 times.
✗ Branch 3 not taken.
7236747 if(!p_igetw(&temp_combo.tile,f))
17242 {
17243 return qe_invalid;
17244 }
17245 }
17246 7439715 temp_combo.o_tile = temp_combo.tile;
17247
2/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7439715 times.
✗ Branch 3 not taken.
7439715 if(!p_getc(&temp_combo.flip,f))
17248 {
17249 return qe_invalid;
17250 }
17251
17252
2/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7439715 times.
✗ Branch 3 not taken.
7439715 if(!p_getc(&temp_combo.walk,f))
17253 {
17254 return qe_invalid;
17255 }
17256
17257
2/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7439715 times.
✗ Branch 3 not taken.
7439715 if(!p_getc(&temp_combo.type,f))
17258 {
17259 return qe_invalid;
17260 }
17261
17262
2/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7439715 times.
✗ Branch 3 not taken.
7439715 if(!p_getc(&temp_combo.csets,f))
17263 {
17264 return qe_invalid;
17265 }
17266
17267
2/2
✓ Branch 0 taken 69774 times.
✓ Branch 1 taken 7369941 times.
7439715 if(version < 0x193)
17268 {
17269
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17270 return qe_invalid;
17271
17272
2/4
✓ Branch 0 taken 69774 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 69774 times.
✗ Branch 3 not taken.
69774 if(!p_getc(&padding,f))
17273 return qe_invalid;
17274
17275
2/2
✓ Branch 0 taken 32910 times.
✓ Branch 1 taken 36864 times.
69774 if(version < 0x192)
17276 {
17277
1/2
✓ Branch 0 taken 36864 times.
✗ Branch 1 not taken.
36864 if(version == 0x191)
17278 {
17279 for(int32_t tmpcounter=0; tmpcounter<16; tmpcounter++)
17280 {
17281 if(!p_getc(&padding,f))
17282 return qe_invalid;
17283 }
17284 }
17285 36864 }
17286 69774 }
17287
2/2
✓ Branch 0 taken 7402851 times.
✓ Branch 1 taken 36864 times.
7439715 if(version >= 0x192)
17288 {
17289
2/4
✓ Branch 0 taken 7402851 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7402851 times.
✗ Branch 3 not taken.
7402851 if(!p_getc(&temp_combo.frames,f))
17290 return qe_invalid;
17291
17292
2/4
✓ Branch 0 taken 7402851 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7402851 times.
✗ Branch 3 not taken.
7402851 if(!p_getc(&temp_combo.speed,f))
17293 return qe_invalid;
17294
17295
2/4
✓ Branch 0 taken 7402851 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7402851 times.
✗ Branch 3 not taken.
7402851 if(!p_igetw(&temp_combo.nextcombo,f))
17296 return qe_invalid;
17297
17298
2/4
✓ Branch 0 taken 7402851 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7402851 times.
✗ Branch 3 not taken.
7402851 if(!p_getc(&temp_combo.nextcset,f))
17299 return qe_invalid;
17300
17301 //Base flag
17302
2/2
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2888408 times.
7402851 if(section_version>=3)
17303
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_getc(&temp_combo.flag,f))
17304 return qe_invalid;
17305
17306
2/2
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2888408 times.
7402851 if(section_version>=4)
17307 {
17308
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_getc(&temp_combo.skipanim,f))
17309 return qe_invalid;
17310
17311
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_igetw(&temp_combo.nexttimer,f))
17312 return qe_invalid;
17313 4514443 }
17314
17315
2/2
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2888408 times.
7402851 if(section_version>=5)
17316
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_getc(&temp_combo.skipanimy,f))
17317 return qe_invalid;
17318
17319
2/2
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2888408 times.
7402851 if(section_version>=6)
17320 {
17321
2/4
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4514443 times.
✗ Branch 3 not taken.
4514443 if(!p_getc(&temp_combo.animflags,f))
17322 return qe_invalid;
17323
17324
1/2
✓ Branch 0 taken 4514443 times.
✗ Branch 1 not taken.
4514443 if(section_version == 6)
17325 temp_combo.animflags = temp_combo.animflags ? AF_FRESH : 0;
17326 4514443 }
17327
17328
2/2
✓ Branch 0 taken 7199883 times.
✓ Branch 1 taken 202968 times.
7402851 if(section_version>=8) //combo Attributes[4] and userflags.
17329 {
17330
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 811872 times.
1014840 for ( int32_t q = 0; q < NUM_COMBO_ATTRIBUTES; q++ )
17331
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_igetl(&temp_combo.attributes[q],f))
17332 return qe_invalid;
17333
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.usrflags,f))
17334 return qe_invalid;
17335
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 if(section_version >= 20)
17336
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.genflags,f))
17337 return qe_invalid;
17338 202968 }
17339
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version>=10) //combo trigger flags
17340 {
17341
2/2
✓ Branch 0 taken 608904 times.
✓ Branch 1 taken 202968 times.
811872 for ( int32_t q = 0; q < 3; q++ )
17342
2/4
✓ Branch 0 taken 608904 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 608904 times.
✗ Branch 3 not taken.
608904 if(!p_igetl(&temp_combo.triggerflags[q],f))
17343 return qe_invalid;
17344 202968 }
17345
1/2
✓ Branch 0 taken 7199883 times.
✗ Branch 1 not taken.
7199883 else if(section_version==9) //combo trigger flags, V9 only had two indices of triggerflags[]
17346 {
17347 for ( int32_t q = 0; q < 2; q++ )
17348 if(!p_igetl(&temp_combo.triggerflags[q],f))
17349 return qe_invalid;
17350 }
17351
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version >= 9)
17352
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.triggerlevel,f))
17353 return qe_invalid;
17354
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version >= 22)
17355
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.triggerbtn,f))
17356 return qe_invalid;
17357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 24)
17358 {
17359 if(!p_getc(&temp_combo.triggeritem,f))
17360 return qe_invalid;
17361 if(!p_getc(&temp_combo.trigtimer,f))
17362 return qe_invalid;
17363 }
17364
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 25)
17365 if(!p_getc(&temp_combo.trigsfx,f))
17366 return qe_invalid;
17367
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 27)
17368 if(!p_igetl(&temp_combo.trigchange,f))
17369 return qe_invalid;
17370
17371
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 29)
17372 {
17373 if(!p_igetw(&temp_combo.trigprox,f))
17374 return qe_invalid;
17375 if(!p_getc(&temp_combo.trigctr,f))
17376 return qe_invalid;
17377 if(!p_igetl(&temp_combo.trigctramnt,f))
17378 return qe_invalid;
17379 }
17380
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 30)
17381 if(!p_getc(&temp_combo.triglbeam,f))
17382 return qe_invalid;
17383
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 31)
17384 {
17385 if(!p_getc(&temp_combo.trigcschange,f))
17386 return qe_invalid;
17387 if(!p_igetw(&temp_combo.spawnitem,f))
17388 return qe_invalid;
17389 if(!p_igetw(&temp_combo.spawnenemy,f))
17390 return qe_invalid;
17391 if(!p_getc(&temp_combo.exstate,f))
17392 return qe_invalid;
17393 if(!p_igetl(&temp_combo.spawnip,f))
17394 return qe_invalid;
17395 if(!p_getc(&temp_combo.trigcopycat,f))
17396 return qe_invalid;
17397 }
17398
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7402851 times.
7402851 if(section_version >= 32)
17399 if(!p_getc(&temp_combo.trigcooldown,f))
17400 return qe_invalid;
17401
17402
2/2
✓ Branch 0 taken 7199883 times.
✓ Branch 1 taken 202968 times.
7402851 if(section_version>=12) //combo label
17403 {
17404 char label[12];
17405 202968 label[11] = '\0';
17406
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 2232648 times.
2435616 for ( int32_t q = 0; q < 11; q++ )
17407
2/4
✓ Branch 0 taken 2232648 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 2232648 times.
✗ Branch 3 not taken.
2232648 if(!p_getc(&label[q],f))
17408 return qe_invalid;
17409
1/2
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
202968 temp_combo.label = label;
17410 202968 }
17411
2/2
✓ Branch 0 taken 7199883 times.
✓ Branch 1 taken 202968 times.
7402851 if(section_version>=13) //attribytes[4]
17412
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 0; q < 4; q++ )
17413
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17414 202968 return qe_invalid;
17415 /* HIGHLY UNORTHODOX UPDATING THING, by Deedee
17416 * This fixes a poor implementation of a ->next flag bug thing.
17417 * Zoria didn't bump up the versions as liberally as he should have, but thankfully
17418 * there was a version bump a few weeks before a change that broke stuff.
17419 */
17420
3/4
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 202968 times.
7402851 if (section_version >= 13 && section_version < 21)
17421 {
17422 set_qr(qr_BUGGY_BUGGY_SLASH_TRIGGERS,1);
17423 }
17424 //combo scripts
17425
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version>=14)
17426 {
17427
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetw(&temp_combo.script,f))
17428 return qe_invalid;
17429
2/2
✓ Branch 0 taken 405936 times.
✓ Branch 1 taken 202968 times.
608904 for ( int32_t q = 0; q < 2; q++ )
17430
2/4
✓ Branch 0 taken 405936 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405936 times.
✗ Branch 3 not taken.
405936 if(!p_igetl(&temp_combo.initd[q],f))
17431 return qe_invalid;
17432 202968 }
17433
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7199883 times.
7402851 if(section_version>=15)
17434 {
17435
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_igetl(&temp_combo.o_tile,f)) return qe_invalid;
17436
2/2
✓ Branch 0 taken 107633 times.
✓ Branch 1 taken 95335 times.
202968 if(!temp_combo.o_tile) temp_combo.o_tile = temp_combo.tile;
17437
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.cur_frame,f)) return qe_invalid;
17438
2/4
✓ Branch 0 taken 202968 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 202968 times.
✗ Branch 3 not taken.
202968 if(!p_getc(&temp_combo.aclk,f)) return qe_invalid;
17439 202968 }
17440
2/2
✓ Branch 0 taken 7199883 times.
✓ Branch 1 taken 202968 times.
7402851 if(section_version>=17) //attribytes[4]
17441 {
17442
2/2
✓ Branch 0 taken 811872 times.
✓ Branch 1 taken 202968 times.
1014840 for ( int32_t q = 4; q < 8; q++ ) //bump up attribytes...
17443
2/4
✓ Branch 0 taken 811872 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 811872 times.
✗ Branch 3 not taken.
811872 if(!p_getc(&temp_combo.attribytes[q],f))
17444 return qe_invalid;
17445
2/2
✓ Branch 0 taken 1623744 times.
✓ Branch 1 taken 202968 times.
1826712 for ( int32_t q = 0; q < 8; q++ ) //...and add attrishorts
17446
2/4
✓ Branch 0 taken 1623744 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1623744 times.
✗ Branch 3 not taken.
1623744 if(!p_igetw(&temp_combo.attrishorts[q],f))
17447 return qe_invalid;
17448 202968 }
17449
17450
2/2
✓ Branch 0 taken 7369941 times.
✓ Branch 1 taken 32910 times.
7402851 if(version < 0x193)
17451
2/2
✓ Branch 0 taken 362010 times.
✓ Branch 1 taken 32910 times.
394920 for(int32_t q=0; q<11; q++)
17452
2/4
✓ Branch 0 taken 362010 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 362010 times.
✗ Branch 3 not taken.
362010 if(!p_getc(&dummy,f))
17453 32910 return qe_invalid;
17454 7402851 }
17455
17456 //Goriya tiles were flipped around in 2.11 build 7. Compensate for the flip here. -DD
17457
3/6
✓ Branch 0 taken 4514443 times.
✓ Branch 1 taken 2925272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 4514443 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
7439715 if((version < 0x211)||((version == 0x211)&&(build<7)))
17458 {
17459
2/2
✓ Branch 0 taken 2885336 times.
✓ Branch 1 taken 39936 times.
2925272 if(!get_qr(qr_NEWENEMYTILES))
17460 {
17461
1/5
✓ Branch 0 taken 39936 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
39936 switch(temp_combo.tile)
17462 {
17463 case 130:
17464 temp_combo.tile = 132;
17465 break;
17466
17467 case 131:
17468 temp_combo.tile = 133;
17469 break;
17470
17471 case 132:
17472 temp_combo.tile = 130;
17473 break;
17474
17475 case 133:
17476 temp_combo.tile = 131;
17477 break;
17478 }
17479 39936 }
17480 2925272 }
17481
17482
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if(section_version < 15)
17483 7236747 temp_combo.o_tile = temp_combo.tile;
17484
17485
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if(section_version<18) //upper bits for .walk
17486 7236747 temp_combo.walk |= 0xF0;
17487
17488
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if(section_version < 19)
17489
2/2
✓ Branch 0 taken 28946988 times.
✓ Branch 1 taken 7236747 times.
36183735 for(int32_t q = 0; q < 4; ++q)
17490 36183735 temp_combo.attributes[q] *= 10000L;
17491
17492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 23)
17493 {
17494
2/2
✓ Branch 0 taken 14731 times.
✓ Branch 1 taken 7424984 times.
7439715 switch(temp_combo.type) //combotriggerCMBTYPEFX now required for combotype-specific effects
17495 {
17496 case cSCRIPT1: case cSCRIPT2: case cSCRIPT3: case cSCRIPT4: case cSCRIPT5:
17497 case cSCRIPT6: case cSCRIPT7: case cSCRIPT8: case cSCRIPT9: case cSCRIPT10:
17498 case cTRIGGERGENERIC: case cCSWITCH:
17499 14731 temp_combo.triggerflags[0] |= combotriggerCMBTYPEFX;
17500 14731 }
17501 7439715 }
17502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 25)
17503 {
17504
2/2
✓ Branch 0 taken 26963 times.
✓ Branch 1 taken 7412752 times.
7439715 switch(temp_combo.type)
17505 {
17506 case cLOCKBLOCK: case cBOSSLOCKBLOCK:
17507
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 26963 times.
26963 if(!(temp_combo.usrflags & cflag3))
17508 26963 temp_combo.attribytes[3] = WAV_DOOR;
17509 26963 temp_combo.usrflags &= ~cflag3;
17510 26963 break;
17511 }
17512 7439715 }
17513
17514
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 26)
17515
2/2
✓ Branch 0 taken 7438615 times.
✓ Branch 1 taken 1100 times.
7440815 if(temp_combo.type == cARMOS)
17516
1/2
✓ Branch 0 taken 1100 times.
✗ Branch 1 not taken.
1100 if(temp_combo.usrflags & cflag1)
17517 temp_combo.usrflags |= cflag3;
17518
17519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 27)
17520 {
17521
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(temp_combo.triggerflags[0] & 0x00040000) //'next'
17522 temp_combo.trigchange = 1;
17523
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 else if(temp_combo.triggerflags[0] & 0x00080000) //'prev'
17524 temp_combo.trigchange = -1;
17525 7439715 else temp_combo.trigchange = 0;
17526 7439715 temp_combo.triggerflags[0] &= ~(0x00040000|0x00080000);
17527 7439715 }
17528
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 7439715 times.
7439715 if(section_version < 28)
17529 {
17530
2/2
✓ Branch 0 taken 15216 times.
✓ Branch 1 taken 7424499 times.
7439715 switch(temp_combo.type)
17531 {
17532 case cLOCKBLOCK: case cLOCKEDCHEST:
17533
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15216 times.
15216 if(temp_combo.usrflags & cflag7)
17534 temp_combo.usrflags |= cflag8;
17535 15216 else temp_combo.usrflags &= ~cflag8;
17536 15216 temp_combo.usrflags &= ~cflag7;
17537 15216 break;
17538 }
17539
2/2
✓ Branch 0 taken 751 times.
✓ Branch 1 taken 7438964 times.
7439715 switch(temp_combo.type)
17540 {
17541 case cCHEST: case cLOCKEDCHEST: case cBOSSCHEST:
17542 751 temp_combo.attrishorts[2] = -1;
17543 751 temp_combo.usrflags |= cflag7;
17544 751 break;
17545 }
17546 7439715 }
17547
2/2
✓ Branch 0 taken 202968 times.
✓ Branch 1 taken 7236747 times.
7439715 if(section_version < 20)
17548 {
17549 7236747 temp_combo.genflags = 0;
17550
2/2
✓ Branch 0 taken 141882 times.
✓ Branch 1 taken 7094865 times.
7236747 switch(temp_combo.type)
17551 {
17552 case cPUSH_WAIT: case cPUSH_HEAVY:
17553 case cPUSH_HW: case cL_STATUE:
17554 case cR_STATUE: case cPUSH_HEAVY2:
17555 case cPUSH_HW2: case cPOUND:
17556 case cC_STATUE: case cMIRROR:
17557 case cMIRRORSLASH: case cMIRRORBACKSLASH:
17558 case cMAGICPRISM: case cMAGICPRISM4:
17559 case cMAGICSPONGE: case cEYEBALL_A:
17560 case cEYEBALL_B: case cEYEBALL_4:
17561 case cBUSH: case cFLOWERS:
17562 case cLOCKBLOCK: case cLOCKBLOCK2:
17563 case cBOSSLOCKBLOCK: case cBOSSLOCKBLOCK2:
17564 case cCHEST: case cCHEST2:
17565 case cLOCKEDCHEST: case cLOCKEDCHEST2:
17566 case cBOSSCHEST: case cBOSSCHEST2:
17567 case cBUSHNEXT: case cBUSHTOUCHY:
17568 case cFLOWERSTOUCHY: case cBUSHNEXTTOUCHY:
17569 case cSIGNPOST: case cCSWITCHBLOCK:
17570 case cTORCH: case cTRIGGERGENERIC:
17571
1/2
✓ Branch 0 taken 141882 times.
✗ Branch 1 not taken.
141882 if(temp_combo.usrflags & cflag16)
17572 {
17573 temp_combo.genflags |= cflag1;
17574 temp_combo.usrflags &= ~cflag16;
17575 }
17576 141882 break;
17577 }
17578 7236747 }
17579
17580 7439715 update_combo(temp_combo, section_version);
17581
17582
3/4
✓ Branch 0 taken 7439715 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 7424796 times.
✓ Branch 3 taken 14919 times.
7439715 if(i>=start_combo && !should_skip)
17583 {
17584
1/2
✓ Branch 0 taken 7424796 times.
✗ Branch 1 not taken.
7424796 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
17585 {
17586 temp_combo.script = 0;
17587 for(int q = 0; q < 8; ++q)
17588 temp_combo.initd[q] = 0;
17589 }
17590
1/2
✓ Branch 0 taken 7424796 times.
✗ Branch 1 not taken.
7424796 combobuf[i] = temp_combo;
17591 7424796 }
17592 7439715 }
17593
17594
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 1 times.
277 if (should_skip)
17595 1 return 0;
17596
17597
5/6
✓ Branch 0 taken 258 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 253 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
276 if((version < 0x192)|| ((version == 0x192)&&(build<185)))
17598 {
17599
2/2
✓ Branch 0 taken 1501440 times.
✓ Branch 1 taken 23 times.
1501463 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17600 {
17601
2/2
✓ Branch 0 taken 1501225 times.
✓ Branch 1 taken 215 times.
1501440 if(combobuf[tmpcounter].type==cHOOKSHOTONLY)
17602 {
17603 215 combobuf[tmpcounter].type=cLADDERHOOKSHOT;
17604 215 }
17605 1501440 }
17606 23 }
17607
17608 //June 3 2012; ladder only is broken in 2.10 and allows the hookshot also. -Gleeok
17609
4/6
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 217 times.
✓ Branch 2 taken 59 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 59 times.
276 if(version == 0x210 && !is_editor())
17610 {
17611
2/2
✓ Branch 0 taken 3851520 times.
✓ Branch 1 taken 59 times.
3851579 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17612
2/2
✓ Branch 0 taken 3851335 times.
✓ Branch 1 taken 185 times.
3851705 if(combobuf[tmpcounter].type == cLADDERONLY)
17613 185 combobuf[tmpcounter].type = cLADDERHOOKSHOT;
17614 59 }
17615
17616
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 82 times.
276 if(section_version<7)
17617 {
17618
2/2
✓ Branch 0 taken 5352960 times.
✓ Branch 1 taken 82 times.
5353042 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17619 {
17620
6/9
✓ Branch 0 taken 5350008 times.
✓ Branch 1 taken 853 times.
✓ Branch 2 taken 791 times.
✓ Branch 3 taken 603 times.
✓ Branch 4 taken 174 times.
✓ Branch 5 taken 531 times.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
5352960 switch(combobuf[tmpcounter].type)
17621 {
17622 case cSLASH:
17623 853 combobuf[tmpcounter].type=cSLASHTOUCHY;
17624 853 break;
17625
17626 case cSLASHITEM:
17627 791 combobuf[tmpcounter].type=cSLASHITEMTOUCHY;
17628 791 break;
17629
17630 case cBUSH:
17631 603 combobuf[tmpcounter].type=cBUSHTOUCHY;
17632 603 break;
17633
17634 case cFLOWERS:
17635 174 combobuf[tmpcounter].type=cFLOWERSTOUCHY;
17636 174 break;
17637
17638 case cTALLGRASS:
17639 531 combobuf[tmpcounter].type=cTALLGRASSTOUCHY;
17640 531 break;
17641
17642 case cSLASHNEXT:
17643 combobuf[tmpcounter].type=cSLASHNEXTTOUCHY;
17644 break;
17645
17646 case cSLASHNEXTITEM:
17647 combobuf[tmpcounter].type=cSLASHNEXTITEMTOUCHY;
17648 break;
17649
17650 case cBUSHNEXT:
17651 combobuf[tmpcounter].type=cBUSHNEXTTOUCHY;
17652 break;
17653 }
17654 5352960 }
17655 82 }
17656
2/2
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 271 times.
276 if (section_version < 16)
17657 {
17658
2/2
✓ Branch 0 taken 17690880 times.
✓ Branch 1 taken 271 times.
17691151 for(int32_t tmpcounter=0; tmpcounter<MAXCOMBOS; tmpcounter++)
17659 {
17660
2/2
✓ Branch 0 taken 17662235 times.
✓ Branch 1 taken 28645 times.
17690880 if (combobuf[tmpcounter].type == cWATER)
17661 {
17662 28645 combobuf[tmpcounter].attributes[0] = 40000L;
17663 28645 }
17664 17690880 }
17665 271 }
17666
2/2
✓ Branch 0 taken 273 times.
✓ Branch 1 taken 3 times.
276 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
17667 {
17668 3 combobuf[0].walk = 0xF0;
17669 3 combobuf[0].type = 0;
17670 3 combobuf[0].flag = 0;
17671 3 }
17672
17673 //Now for the new combo alias reset
17674
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 82 times.
276 if(section_version<2)
17675 {
17676
2/2
✓ Branch 0 taken 671744 times.
✓ Branch 1 taken 82 times.
671826 for(int32_t j=0; j<MAXCOMBOALIASES; j++)
17677 {
17678 671744 combo_aliases[j].width = 0;
17679 671744 combo_aliases[j].height = 0;
17680 671744 combo_aliases[j].layermask = 0;
17681
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].combos.clear();
17682
1/2
✓ Branch 0 taken 671744 times.
✗ Branch 1 not taken.
671744 combo_aliases[j].csets.clear();
17683 671744 }
17684 82 }
17685
17686
17687
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 setup_combo_animations();
17688
1/2
✓ Branch 0 taken 276 times.
✗ Branch 1 not taken.
276 setup_combo_animations2();
17689 276 return 0;
17690 277 }
17691 2412301 int32_t readcombo_loop(PACKFILE* f, word s_version, newcombo& temp_combo)
17692 {
17693 byte combo_has_flags;
17694
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2412301 times.
2412301 if(!p_getc(&combo_has_flags,f))
17695 return qe_invalid;
17696
17697 2412301 temp_combo.clear();
17698
2/2
✓ Branch 0 taken 1679677 times.
✓ Branch 1 taken 732624 times.
2412301 if(combo_has_flags)
17699 {
17700
2/2
✓ Branch 0 taken 57 times.
✓ Branch 1 taken 732567 times.
732624 if(combo_has_flags&CHAS_BASIC)
17701 {
17702
1/2
✓ Branch 0 taken 732567 times.
✗ Branch 1 not taken.
732567 if(!p_igetl(&temp_combo.tile,f))
17703 return qe_invalid;
17704 732567 temp_combo.o_tile = temp_combo.tile;
17705
17706
1/2
✓ Branch 0 taken 732567 times.
✗ Branch 1 not taken.
732567 if(!p_getc(&temp_combo.flip,f))
17707 return qe_invalid;
17708
17709
1/2
✓ Branch 0 taken 732567 times.
✗ Branch 1 not taken.
732567 if(!p_getc(&temp_combo.walk,f))
17710 return qe_invalid;
17711
17712
1/2
✓ Branch 0 taken 732567 times.
✗ Branch 1 not taken.
732567 if(!p_getc(&temp_combo.type,f))
17713 return qe_invalid;
17714
17715
1/2
✓ Branch 0 taken 732567 times.
✗ Branch 1 not taken.
732567 if(!p_getc(&temp_combo.flag,f))
17716 return qe_invalid;
17717
17718
1/2
✓ Branch 0 taken 732567 times.
✗ Branch 1 not taken.
732567 if(!p_getc(&temp_combo.csets,f))
17719 return qe_invalid;
17720 732567 }
17721
2/2
✓ Branch 0 taken 729809 times.
✓ Branch 1 taken 2815 times.
732624 if(combo_has_flags&CHAS_SCRIPT)
17722 {
17723
2/2
✓ Branch 0 taken 2785 times.
✓ Branch 1 taken 30 times.
2815 if (s_version>=41)
17724 {
17725 2785 p_getcstr(&temp_combo.label, f);
17726 2785 }
17727 else
17728 {
17729 char label[12];
17730 30 label[11] = '\0';
17731
2/2
✓ Branch 0 taken 330 times.
✓ Branch 1 taken 30 times.
360 for ( int32_t q = 0; q < 11; q++ )
17732
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 330 times.
330 if(!p_getc(&label[q],f))
17733 return qe_invalid;
17734 30 temp_combo.label = label;
17735 }
17736
17737
1/2
✓ Branch 0 taken 2815 times.
✗ Branch 1 not taken.
2815 if(!p_igetw(&temp_combo.script,f)) return qe_invalid;
17738 2815 auto initd_count = s_version >= 43 ? 8 : 2;
17739
2/2
✓ Branch 0 taken 22340 times.
✓ Branch 1 taken 2815 times.
25155 for ( int32_t q = 0; q < initd_count; q++ )
17740
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 22340 times.
22340 if(!p_igetl(&temp_combo.initd[q],f))
17741 return qe_invalid;
17742 2815 }
17743
2/2
✓ Branch 0 taken 580092 times.
✓ Branch 1 taken 152532 times.
732624 if(combo_has_flags&CHAS_ANIM)
17744 {
17745
1/2
✓ Branch 0 taken 152532 times.
✗ Branch 1 not taken.
152532 if(!p_getc(&temp_combo.frames,f))
17746 return qe_invalid;
17747
17748
1/2
✓ Branch 0 taken 152532 times.
✗ Branch 1 not taken.
152532 if(!p_getc(&temp_combo.speed,f))
17749 return qe_invalid;
17750
17751
1/2
✓ Branch 0 taken 152532 times.
✗ Branch 1 not taken.
152532 if(!p_igetw(&temp_combo.nextcombo,f))
17752 return qe_invalid;
17753
17754
1/2
✓ Branch 0 taken 152532 times.
✗ Branch 1 not taken.
152532 if(!p_getc(&temp_combo.nextcset,f))
17755 return qe_invalid;
17756
17757
1/2
✓ Branch 0 taken 152532 times.
✗ Branch 1 not taken.
152532 if(!p_getc(&temp_combo.skipanim,f))
17758 return qe_invalid;
17759
17760
1/2
✓ Branch 0 taken 152532 times.
✗ Branch 1 not taken.
152532 if(!p_getc(&temp_combo.skipanimy,f))
17761 return qe_invalid;
17762
17763
1/2
✓ Branch 0 taken 152532 times.
✗ Branch 1 not taken.
152532 if(!p_getc(&temp_combo.animflags,f))
17764 return qe_invalid;
17765 152532 }
17766
2/2
✓ Branch 0 taken 650462 times.
✓ Branch 1 taken 82162 times.
732624 if(combo_has_flags&CHAS_ATTRIB)
17767 {
17768
2/2
✓ Branch 0 taken 328648 times.
✓ Branch 1 taken 82162 times.
410810 for ( int32_t q = 0; q < 4; q++ )
17769
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 328648 times.
328648 if(!p_igetl(&temp_combo.attributes[q],f))
17770 return qe_invalid;
17771
2/2
✓ Branch 0 taken 657296 times.
✓ Branch 1 taken 82162 times.
739458 for ( int32_t q = 0; q < 8; q++ )
17772
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657296 times.
657296 if(!p_getc(&temp_combo.attribytes[q],f))
17773 return qe_invalid;
17774
2/2
✓ Branch 0 taken 657296 times.
✓ Branch 1 taken 82162 times.
739458 for ( int32_t q = 0; q < 8; q++ )
17775
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 657296 times.
657296 if(!p_igetw(&temp_combo.attrishorts[q],f))
17776 return qe_invalid;
17777 82162 }
17778
2/2
✓ Branch 0 taken 704404 times.
✓ Branch 1 taken 28220 times.
732624 if(combo_has_flags&CHAS_FLAG)
17779 {
17780
1/2
✓ Branch 0 taken 28220 times.
✗ Branch 1 not taken.
28220 if(!p_igetl(&temp_combo.usrflags,f))
17781 return qe_invalid;
17782
1/2
✓ Branch 0 taken 28220 times.
✗ Branch 1 not taken.
28220 if(!p_igetw(&temp_combo.genflags,f))
17783 return qe_invalid;
17784 28220 }
17785
2/2
✓ Branch 0 taken 715756 times.
✓ Branch 1 taken 16868 times.
732624 if(combo_has_flags&CHAS_TRIG)
17786 {
17787 16868 int numtrigs = s_version < 36 ? 3 : 6;
17788
2/2
✓ Branch 0 taken 100350 times.
✓ Branch 1 taken 16868 times.
117218 for ( int32_t q = 0; q < numtrigs; q++ )
17789
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 100350 times.
100350 if(!p_igetl(&temp_combo.triggerflags[q],f))
17790 return qe_invalid;
17791
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetl(&temp_combo.triggerlevel,f))
17792 return qe_invalid;
17793
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.triggerbtn,f))
17794 return qe_invalid;
17795
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.triggeritem,f))
17796 return qe_invalid;
17797
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.trigtimer,f))
17798 return qe_invalid;
17799
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.trigsfx,f))
17800 return qe_invalid;
17801
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetl(&temp_combo.trigchange,f))
17802 return qe_invalid;
17803
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetw(&temp_combo.trigprox,f))
17804 return qe_invalid;
17805
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.trigctr,f))
17806 return qe_invalid;
17807
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetl(&temp_combo.trigctramnt,f))
17808 return qe_invalid;
17809
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.triglbeam,f))
17810 return qe_invalid;
17811
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.trigcschange,f))
17812 return qe_invalid;
17813
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetw(&temp_combo.spawnitem,f))
17814 return qe_invalid;
17815
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetw(&temp_combo.spawnenemy,f))
17816 return qe_invalid;
17817
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.exstate,f))
17818 return qe_invalid;
17819
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetl(&temp_combo.spawnip,f))
17820 return qe_invalid;
17821
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.trigcopycat,f))
17822 return qe_invalid;
17823
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.trigcooldown,f))
17824 return qe_invalid;
17825
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 16868 times.
16868 if(s_version >= 35)
17826 {
17827
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetw(&temp_combo.prompt_cid,f))
17828 return qe_invalid;
17829
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_getc(&temp_combo.prompt_cs,f))
17830 return qe_invalid;
17831
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetw(&temp_combo.prompt_x,f))
17832 return qe_invalid;
17833
1/2
✓ Branch 0 taken 16868 times.
✗ Branch 1 not taken.
16868 if(!p_igetw(&temp_combo.prompt_y,f))
17834 return qe_invalid;
17835 16868 }
17836
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16582 times.
16868 if(s_version >= 36)
17837 {
17838
1/2
✓ Branch 0 taken 16582 times.
✗ Branch 1 not taken.
16582 if(!p_getc(&temp_combo.trig_lstate,f))
17839 return qe_invalid;
17840
1/2
✓ Branch 0 taken 16582 times.
✗ Branch 1 not taken.
16582 if(!p_getc(&temp_combo.trig_gstate,f))
17841 return qe_invalid;
17842
1/2
✓ Branch 0 taken 16582 times.
✗ Branch 1 not taken.
16582 if(!p_igetl(&temp_combo.trig_statetime,f))
17843 return qe_invalid;
17844 16582 }
17845
2/2
✓ Branch 0 taken 286 times.
✓ Branch 1 taken 16582 times.
16868 if(s_version >= 37)
17846 {
17847
1/2
✓ Branch 0 taken 16582 times.
✗ Branch 1 not taken.
16582 if(!p_igetw(&temp_combo.trig_genscr,f))
17848 return qe_invalid;
17849 16582 }
17850
2/2
✓ Branch 0 taken 434 times.
✓ Branch 1 taken 16434 times.
16868 if(s_version >= 38)
17851 {
17852
1/2
✓ Branch 0 taken 16434 times.
✗ Branch 1 not taken.
16434 if(!p_getc(&temp_combo.trig_group,f))
17853 return qe_invalid;
17854
1/2
✓ Branch 0 taken 16434 times.
✗ Branch 1 not taken.
16434 if(!p_igetw(&temp_combo.trig_group_val,f))
17855 return qe_invalid;
17856 16434 }
17857
2/2
✓ Branch 0 taken 479 times.
✓ Branch 1 taken 16389 times.
16868 if(s_version >= 45)
17858 {
17859
1/2
✓ Branch 0 taken 16389 times.
✗ Branch 1 not taken.
16389 if(!p_getc(&temp_combo.exdoor_dir,f))
17860 return qe_invalid;
17861
1/2
✓ Branch 0 taken 16389 times.
✗ Branch 1 not taken.
16389 if(!p_getc(&temp_combo.exdoor_ind,f))
17862 return qe_invalid;
17863 16389 }
17864
2/2
✓ Branch 0 taken 12766 times.
✓ Branch 1 taken 4102 times.
16868 if(s_version >= 46)
17865 {
17866
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_getc(&temp_combo.trig_levelitems,f))
17867 return qe_invalid;
17868
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trigdmlevel,f))
17869 return qe_invalid;
17870
2/2
✓ Branch 0 taken 1355 times.
✓ Branch 1 taken 2747 times.
4102 if(s_version >= 48)
17871 {
17872
2/2
✓ Branch 0 taken 4065 times.
✓ Branch 1 taken 1355 times.
5420 for(int q = 0; q < 3; ++q)
17873
1/2
✓ Branch 0 taken 4065 times.
✗ Branch 1 not taken.
4065 if(!p_igetw(&temp_combo.trigtint[q],f))
17874 return qe_invalid;
17875 1355 }
17876 else
17877 {
17878
2/2
✓ Branch 0 taken 8241 times.
✓ Branch 1 taken 2747 times.
10988 for(int q = 0; q < 3; ++q)
17879
1/2
✓ Branch 0 taken 8241 times.
✗ Branch 1 not taken.
8241 if(!p_getc(&temp_combo.trigtint[q],f))
17880 return qe_invalid;
17881
2/2
✓ Branch 0 taken 8241 times.
✓ Branch 1 taken 2747 times.
10988 for(int q = 0; q < 3; ++q)
17882 {
17883 8241 int v = temp_combo.trigtint[q];
17884 8241 int va = abs(v);
17885 8241 temp_combo.trigtint[q] = _rgb_scale_6[va] * sign(v);
17886 8241 }
17887 }
17888
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.triglvlpalette,f))
17889 return qe_invalid;
17890
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trigbosspalette,f))
17891 return qe_invalid;
17892
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trigquaketime,f))
17893 return qe_invalid;
17894
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trigwavytime,f))
17895 return qe_invalid;
17896
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trig_swjinxtime,f))
17897 return qe_invalid;
17898
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trig_itmjinxtime,f))
17899 return qe_invalid;
17900
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trig_stuntime,f))
17901 return qe_invalid;
17902
1/2
✓ Branch 0 taken 4102 times.
✗ Branch 1 not taken.
4102 if(!p_igetw(&temp_combo.trig_bunnytime,f))
17903 return qe_invalid;
17904
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4102 times.
4102 if(!p_getc(&temp_combo.trig_pushtime,f))
17905 return qe_invalid;
17906 4102 }
17907
2/2
✓ Branch 0 taken 15513 times.
✓ Branch 1 taken 1355 times.
16868 if(s_version >= 47)
17908 {
17909
1/2
✓ Branch 0 taken 1355 times.
✗ Branch 1 not taken.
1355 if (!p_igetw(&temp_combo.trig_shieldjinxtime, f))
17910 return qe_invalid;
17911 1355 }
17912 16868 }
17913
2/2
✓ Branch 0 taken 730487 times.
✓ Branch 1 taken 2137 times.
732624 if(combo_has_flags&CHAS_LIFT)
17914 {
17915
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_igetw(&temp_combo.liftcmb,f))
17916 return qe_invalid;
17917
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftcs,f))
17918 return qe_invalid;
17919
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_igetw(&temp_combo.liftundercmb,f))
17920 return qe_invalid;
17921
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftundercs,f))
17922 return qe_invalid;
17923
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftdmg,f))
17924 return qe_invalid;
17925
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftlvl,f))
17926 return qe_invalid;
17927
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftitm,f))
17928 return qe_invalid;
17929
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftflags,f))
17930 return qe_invalid;
17931
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftgfx,f))
17932 return qe_invalid;
17933
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftsprite,f))
17934 return qe_invalid;
17935
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftsfx,f))
17936 return qe_invalid;
17937
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_igetw(&temp_combo.liftbreaksprite,f))
17938 return qe_invalid;
17939
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.liftbreaksfx,f))
17940 return qe_invalid;
17941
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2137 times.
2137 if(s_version >= 34)
17942 {
17943
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.lifthei,f))
17944 return qe_invalid;
17945
1/2
✓ Branch 0 taken 2137 times.
✗ Branch 1 not taken.
2137 if(!p_getc(&temp_combo.lifttime,f))
17946 return qe_invalid;
17947 2137 }
17948
2/2
✓ Branch 0 taken 14 times.
✓ Branch 1 taken 2123 times.
2137 if(s_version >= 39)
17949 {
17950
1/2
✓ Branch 0 taken 2123 times.
✗ Branch 1 not taken.
2123 if(!p_getc(&temp_combo.lift_parent_item,f))
17951 return qe_invalid;
17952 2123 }
17953 2137 }
17954
2/2
✓ Branch 0 taken 731316 times.
✓ Branch 1 taken 1308 times.
732624 if(combo_has_flags&CHAS_GENERAL)
17955 {
17956
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.speed_mult,f))
17957 return qe_invalid;
17958
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.speed_div,f))
17959 return qe_invalid;
17960
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_igetzf(&temp_combo.speed_add,f))
17961 return qe_invalid;
17962
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1308 times.
1308 if(s_version >= 42)
17963 {
17964
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.sfx_appear,f))
17965 return qe_invalid;
17966
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.sfx_disappear,f))
17967 return qe_invalid;
17968
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.sfx_loop,f))
17969 return qe_invalid;
17970
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.sfx_walking,f))
17971 return qe_invalid;
17972
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.sfx_standing,f))
17973 return qe_invalid;
17974
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.spr_appear,f))
17975 return qe_invalid;
17976
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.spr_disappear,f))
17977 return qe_invalid;
17978
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.spr_walking,f))
17979 return qe_invalid;
17980
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.spr_standing,f))
17981 return qe_invalid;
17982 1308 }
17983
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1308 times.
1308 if(s_version >= 44)
17984 {
17985
1/2
✓ Branch 0 taken 1308 times.
✗ Branch 1 not taken.
1308 if(!p_getc(&temp_combo.sfx_tap,f))
17986 return qe_invalid;
17987 1308 }
17988 1308 }
17989 732624 }
17990 2412301 update_combo(temp_combo, s_version);
17991 2412301 return 0;
17992 2412301 }
17993 695 int32_t readcombos(PACKFILE *f, zquestheader *Header, word version, word build, word start_combo, word max_combos)
17994 {
17995
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_combos);
17996
17997 695 word section_version=0;
17998 695 word section_cversion=0;
17999 695 word combos_used=0;
18000 int32_t dummy;
18001 byte padding;
18002 695 newcombo temp_combo;
18003
18004
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 694 times.
695 if (!should_skip)
18005 {
18006
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 reset_combo_animations();
18007
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 reset_combo_animations2();
18008
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 init_combo_classes();
18009
18010
2/2
✓ Branch 0 taken 45304320 times.
✓ Branch 1 taken 694 times.
45305014 for(int32_t q = start_combo; q < start_combo+max_combos; ++q)
18011
1/2
✓ Branch 0 taken 45304320 times.
✗ Branch 1 not taken.
45304320 combobuf[q].clear();
18012 694 }
18013
18014
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 if(version > 0x192) //Version info
18015 {
18016
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&section_version,f))
18017 {
18018 return qe_invalid;
18019 }
18020 671 FFCore.quest_format[vCombos] = section_version;
18021
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&section_cversion,f))
18022 {
18023 return qe_invalid;
18024 }
18025
18026 //section size
18027
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetl(&dummy,f))
18028 {
18029 return qe_invalid;
18030 }
18031 671 }
18032
18033
2/2
✓ Branch 0 taken 418 times.
✓ Branch 1 taken 277 times.
695 if(section_version > 32) //Cleanup time!
18034 {
18035
2/4
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 418 times.
✗ Branch 3 not taken.
418 if(!p_igetw(&combos_used,f))
18036 {
18037 return qe_invalid;
18038 }
18039
2/2
✓ Branch 0 taken 2412301 times.
✓ Branch 1 taken 418 times.
2412719 for(int32_t i=0; i<combos_used; i++)
18040 {
18041
1/2
✓ Branch 0 taken 2412301 times.
✗ Branch 1 not taken.
2412301 auto ret = readcombo_loop(f,section_version,temp_combo);
18042
1/2
✓ Branch 0 taken 2412301 times.
✗ Branch 1 not taken.
2412301 if(ret) return ret;
18043
1/2
✓ Branch 0 taken 2412301 times.
✗ Branch 1 not taken.
2412301 if(i>=start_combo)
18044 {
18045
1/2
✓ Branch 0 taken 2412301 times.
✗ Branch 1 not taken.
2412301 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
18046 {
18047 temp_combo.script = 0;
18048 for(int q = 0; q < 8; ++q)
18049 temp_combo.initd[q] = 0;
18050 }
18051
1/2
✓ Branch 0 taken 2412301 times.
✗ Branch 1 not taken.
2412301 combobuf[i] = temp_combo;
18052 2412301 }
18053 2412301 }
18054 418 }
18055 else //Call the old function for all old versions
18056 {
18057
1/2
✓ Branch 0 taken 277 times.
✗ Branch 1 not taken.
277 auto ret = readcombos_old(section_version,f,Header,version,build,start_combo,max_combos);
18058
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 277 times.
277 if(ret) return ret; //error, end read
18059 }
18060
18061
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 1 times.
695 if (should_skip)
18062 1 return 0;
18063
18064
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 411 times.
694 if(!get_qr(qr_ALLOW_EDITING_COMBO_0))
18065 {
18066 411 combobuf[0].walk = 0xF0;
18067 411 combobuf[0].type = 0;
18068 411 combobuf[0].flag = 0;
18069 411 }
18070
18071
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 setup_combo_animations();
18072
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 setup_combo_animations2();
18073 694 return 0;
18074 695 }
18075
18076 612 int32_t readcomboaliases(PACKFILE *f, zquestheader *Header, word version, word build)
18077 {
18078 //these are here to bypass compiler warnings about unused arguments
18079 612 Header=Header;
18080 612 version=version;
18081 612 build=build;
18082
18083 int32_t dummy;
18084 612 word sversion=0, c_sversion;
18085
18086 //section version info
18087
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(!p_igetw(&sversion,f))
18088 {
18089 return qe_invalid;
18090 }
18091
18092 612 FFCore.quest_format[vComboAliases] = sversion;
18093
18094
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&c_sversion,f))
18095 {
18096 return qe_invalid;
18097 }
18098
18099 //section size
18100
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetl(&dummy,f))
18101 {
18102 return qe_invalid;
18103 }
18104
18105 612 int32_t max_num_combo_aliases = MAXCOMBOALIASES;
18106
18107
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 189 times.
612 if(sversion < 3) // max saved combo alias' upped from 256 to 2048.
18108 {
18109 189 max_num_combo_aliases = MAX250COMBOALIASES;
18110 189 }
18111
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(sversion < 2) // max saved combo alias' upped from 256 to 2048.
18112 {
18113 max_num_combo_aliases = OLDMAXCOMBOALIASES;
18114 }
18115
18116
2/2
✓ Branch 0 taken 3852288 times.
✓ Branch 1 taken 612 times.
3852900 for(int32_t j=0; j<max_num_combo_aliases; j++)
18117 {
18118 byte width,height,mask,tempcset;
18119 int32_t count;
18120 word tempword;
18121 byte tempbyte;
18122
18123
1/2
✓ Branch 0 taken 3852288 times.
✗ Branch 1 not taken.
3852288 if(!p_igetw(&tempword,f))
18124 {
18125 return qe_invalid;
18126 }
18127
18128 3852288 combo_aliases[j].combo = tempword;
18129
18130
1/2
✓ Branch 0 taken 3852288 times.
✗ Branch 1 not taken.
3852288 if(!p_getc(&tempbyte,f))
18131 {
18132 return qe_invalid;
18133 }
18134
18135 3852288 combo_aliases[j].cset = tempbyte;
18136
18137
1/2
✓ Branch 0 taken 3852288 times.
✗ Branch 1 not taken.
3852288 if(!p_getc(&width,f))
18138 {
18139 return qe_invalid;
18140 }
18141
18142
1/2
✓ Branch 0 taken 3852288 times.
✗ Branch 1 not taken.
3852288 if(!p_getc(&height,f))
18143 {
18144 return qe_invalid;
18145 }
18146
18147
1/2
✓ Branch 0 taken 3852288 times.
✗ Branch 1 not taken.
3852288 if(!p_getc(&mask,f))
18148 {
18149 return qe_invalid;
18150 }
18151
18152 3852288 count=(width+1)*(height+1)*(comboa_lmasktotal(mask)+1);
18153
18154 3852288 combo_aliases[j].width = width;
18155 3852288 combo_aliases[j].height = height;
18156 3852288 combo_aliases[j].layermask = mask;
18157 3852288 combo_aliases[j].combos.clear();
18158 3852288 combo_aliases[j].csets.clear();
18159
18160
2/2
✓ Branch 0 taken 3960704 times.
✓ Branch 1 taken 3852288 times.
7812992 for(int32_t k=0; k<count; k++)
18161 {
18162
1/2
✓ Branch 0 taken 3960704 times.
✗ Branch 1 not taken.
3960704 if(!p_igetw(&tempword,f))
18163 {
18164 return qe_invalid;
18165 }
18166
18167 3960704 combo_aliases[j].combos[k] = tempword;
18168 3960704 }
18169
18170
2/2
✓ Branch 0 taken 3960704 times.
✓ Branch 1 taken 3852288 times.
7812992 for(int32_t k=0; k<count; k++)
18171 {
18172
1/2
✓ Branch 0 taken 3960704 times.
✗ Branch 1 not taken.
3960704 if(!p_getc(&tempcset,f))
18173 {
18174 return qe_invalid;
18175 }
18176
18177 3960704 combo_aliases[j].csets[k] = tempcset;
18178 3960704 }
18179 3852288 }
18180
18181 //Combo pools!
18182 612 word num_combo_pools = 0;
18183
2/2
✓ Branch 0 taken 194 times.
✓ Branch 1 taken 418 times.
612 if(sversion >= 4)
18184 {
18185
1/2
✓ Branch 0 taken 418 times.
✗ Branch 1 not taken.
418 if(!p_igetw(&num_combo_pools,f))
18186 {
18187 return qe_invalid;
18188 }
18189 418 }
18190
18191
2/2
✓ Branch 0 taken 5013504 times.
✓ Branch 1 taken 612 times.
5014116 for(combo_pool& pool : combo_pools)
18192 {
18193 5013504 pool.clear();
18194 }
18195
18196 612 combo_pool temp_cpool;
18197
2/2
✓ Branch 0 taken 1278 times.
✓ Branch 1 taken 612 times.
1890 for(word cp = 0; cp < num_combo_pools; ++cp)
18198 {
18199 1278 int32_t num_combos_in_pool = 0;
18200
2/4
✓ Branch 0 taken 1278 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1278 times.
✗ Branch 3 not taken.
1278 if(!p_igetl(&num_combos_in_pool,f))
18201 {
18202 return qe_invalid;
18203 }
18204
2/2
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 96 times.
1278 if(num_combos_in_pool < 1) continue; //nothing to read
18205
18206
1/2
✓ Branch 0 taken 1182 times.
✗ Branch 1 not taken.
1182 temp_cpool.clear();
18207
18208 int32_t cp_cid; int8_t cp_cs; word cp_quant;
18209
2/2
✓ Branch 0 taken 1182 times.
✓ Branch 1 taken 5190 times.
6372 for(auto q = 0; q < num_combos_in_pool; ++q)
18210 {
18211
2/4
✓ Branch 0 taken 5190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5190 times.
✗ Branch 3 not taken.
5190 if(!p_igetl(&cp_cid,f))
18212 {
18213 return qe_invalid;
18214 }
18215
2/4
✓ Branch 0 taken 5190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5190 times.
✗ Branch 3 not taken.
5190 if(!p_getc(&cp_cs,f))
18216 {
18217 return qe_invalid;
18218 }
18219
2/4
✓ Branch 0 taken 5190 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 5190 times.
✗ Branch 3 not taken.
5190 if(!p_igetw(&cp_quant,f))
18220 {
18221 return qe_invalid;
18222 }
18223
1/2
✓ Branch 0 taken 5190 times.
✗ Branch 1 not taken.
5190 temp_cpool.add(cp_cid, cp_cs, cp_quant);
18224 5190 }
18225
18226
1/2
✓ Branch 0 taken 1182 times.
✗ Branch 1 not taken.
1182 combo_pools[cp] = temp_cpool;
18227 1182 }
18228
18229 //Autocombos!
18230 612 word num_combo_autos = 0;
18231
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 207 times.
612 if (sversion >= 5)
18232 {
18233
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if (!p_igetw(&num_combo_autos, f))
18234 {
18235 return qe_invalid;
18236 }
18237 405 }
18238
18239
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 5013504 times.
5014116 for (combo_auto& cauto : combo_autos)
18240 {
18241
1/2
✓ Branch 0 taken 5013504 times.
✗ Branch 1 not taken.
5013504 cauto.clear(true);
18242 }
18243
18244
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 combo_auto temp_cauto;
18245
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 612 times.
1506 for (word ca = 0; ca < num_combo_autos; ++ca)
18246 {
18247 byte type;
18248 int32_t display_cid, erase_cid;
18249 byte flags, arg;
18250
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if (!p_getc(&type, f))
18251 {
18252 return qe_invalid;
18253 }
18254
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if (!p_igetl(&display_cid, f))
18255 {
18256 return qe_invalid;
18257 }
18258
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if (!p_igetl(&erase_cid, f))
18259 {
18260 return qe_invalid;
18261 }
18262
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if (!p_getc(&flags, f))
18263 {
18264 return qe_invalid;
18265 }
18266
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if (!p_getc(&arg, f))
18267 {
18268 return qe_invalid;
18269 }
18270 894 int32_t num_combos_in_cauto = 0;
18271
2/4
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 894 times.
✗ Branch 3 not taken.
894 if (!p_igetl(&num_combos_in_cauto, f))
18272 {
18273 return qe_invalid;
18274 }
18275
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 if (num_combos_in_cauto < 1) continue; //nothing to read
18276
18277
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 temp_cauto.clear();
18278
18279
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 temp_cauto.setType(type);
18280
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 temp_cauto.setDisplay(display_cid);
18281
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 temp_cauto.setEraseCombo(erase_cid);
18282
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 temp_cauto.setFlags(flags);
18283
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 temp_cauto.setArg(arg);
18284
18285 int32_t ca_cid; byte ca_ctype; int16_t ca_offset; int16_t ca_engrave_offset;
18286
2/2
✓ Branch 0 taken 894 times.
✓ Branch 1 taken 11304 times.
12198 for (auto q = 0; q < num_combos_in_cauto; ++q)
18287 {
18288
2/4
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
11304 if (!p_getc(&ca_ctype, f))
18289 {
18290 return qe_invalid;
18291 }
18292
2/4
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 11304 times.
✗ Branch 3 not taken.
11304 if (!p_igetl(&ca_cid, f))
18293 {
18294 return qe_invalid;
18295 }
18296
1/2
✓ Branch 0 taken 11304 times.
✗ Branch 1 not taken.
11304 temp_cauto.addEntry(ca_cid, ca_ctype, q, -1);
18297 11304 }
18298
18299
1/2
✓ Branch 0 taken 894 times.
✗ Branch 1 not taken.
894 combo_autos[ca] = temp_cauto;
18300 894 }
18301
18302 612 return 0;
18303 612 }
18304
18305 695 int32_t readcolordata(PACKFILE *f, miscQdata *Misc, word version, word build, word start_cset, word max_csets)
18306 {
18307
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_colors);
18308
18309 //these are here to bypass compiler warnings about unused arguments
18310 //THE *48 REFERS TO EACH CSET BEING 16 COLORS with 3 VALUES OF RGB (3*16 is 48)
18311 //Capitalized cause it'll save you a headache. -Deedee
18312 695 start_cset=start_cset;
18313 695 max_csets=max_csets;
18314 695 word s_version=0;
18315
18316 miscQdata temp_misc;
18317 695 memcpy(&temp_misc, Misc, sizeof(temp_misc));
18318
18319 byte temp_colordata[48];
18320 char temp_palname[PALNAMESIZE+1];
18321
18322 int32_t dummy;
18323 word palcycles;
18324
18325
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 if(version > 0x192)
18326 {
18327 //section version info
18328
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_version,f))
18329 {
18330 return qe_invalid;
18331 }
18332
18333 671 FFCore.quest_format[vCSets] = s_version;
18334
18335
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&dummy,f))
18336 {
18337 return qe_invalid;
18338 }
18339
18340 //section size
18341
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&dummy,f))
18342 {
18343 return qe_invalid;
18344 }
18345 671 }
18346
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 423 times.
695 if (s_version < 5)
18347 {
18348
4/4
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 254 times.
✓ Branch 2 taken 248 times.
✓ Branch 3 taken 6 times.
272 bool RealOldVerion = ((version < 0x192)||((version == 0x192)&&(build<73)));
18349
18350 //finally... section data
18351 272 int32_t q = 0;
18352 272 int32_t p = -15;
18353
2/2
✓ Branch 0 taken 65280 times.
✓ Branch 1 taken 272 times.
65552 for(int32_t i=0; i<oldpdTOTAL; ++i)
18354 {
18355 65280 memset(temp_colordata, 0, 48);
18356
18357
1/2
✓ Branch 0 taken 65280 times.
✗ Branch 1 not taken.
65280 if(!pfread(temp_colordata,48,f))
18358 {
18359 return qe_invalid;
18360 }
18361
18362
2/2
✓ Branch 0 taken 240 times.
✓ Branch 1 taken 65040 times.
65280 if (should_skip)
18363 240 continue;
18364
18365 65040 memcpy(&colordata[q*48], temp_colordata, 48);
18366
18367 65040 ++q;
18368
8/8
✓ Branch 0 taken 60704 times.
✓ Branch 1 taken 4336 times.
✓ Branch 2 taken 4607 times.
✓ Branch 3 taken 56097 times.
✓ Branch 4 taken 542 times.
✓ Branch 5 taken 4065 times.
✓ Branch 6 taken 36 times.
✓ Branch 7 taken 506 times.
65040 if (p > 0 && (p%13)==12 && (i < oldpoSPRITE || !RealOldVerion)) //It's > 0 instead of >= 0 because it should append
18369 {
18370
1/2
✓ Branch 0 taken 4571 times.
✗ Branch 1 not taken.
4571 if (s_version < 5) //Bumping up the size of level palettes
18371 {
18372 4571 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18373 4571 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18374 4571 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18375 4571 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18376 4571 q+=4;
18377 4571 }
18378 else
18379 {
18380 for(int m = 0; m < 4; ++m)
18381 {
18382 memset(temp_colordata, 0, 48);
18383 if(!pfread(temp_colordata,48,f))
18384 {
18385 return qe_invalid;
18386 }
18387 memcpy(&colordata[q*48], temp_colordata, 48);
18388 ++q;
18389 }
18390 }
18391 4571 }
18392 65040 ++p;
18393 65040 }
18394
18395
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 254 times.
272 if(RealOldVerion)
18396 {
18397
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18398 {
18399 18 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18400 18 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18401 18 memcpy(colordata+((poSPRITE255+11)*48), colordata+((poSPRITE255+10)*48), 48);
18402 18 memcpy(colordata+((poSPRITE255+10)*48), colordata+((poSPRITE255+9)*48), 48);
18403 18 memcpy(colordata+((poSPRITE255+9)*48), colordata+((poSPRITE255+8)*48), 48);
18404 18 memset(colordata+((poSPRITE255+8)*48), 0, 48);
18405 18 }
18406 18 }
18407 else
18408 {
18409 254 memset(temp_colordata, 0, 48);
18410
18411
2/2
✓ Branch 0 taken 795782 times.
✓ Branch 1 taken 254 times.
796036 for(int32_t i=0; i<newpdTOTAL-oldpdTOTAL; ++i)
18412 {
18413
1/2
✓ Branch 0 taken 795782 times.
✗ Branch 1 not taken.
795782 if(!pfread(temp_colordata,48,f))
18414 {
18415 return qe_invalid;
18416 }
18417
18418
2/2
✓ Branch 0 taken 3133 times.
✓ Branch 1 taken 792649 times.
795782 if (should_skip)
18419 3133 continue;
18420
18421 792649 memcpy(&colordata[q*48], temp_colordata, 48);
18422
18423 792649 ++q;
18424
7/8
✓ Branch 0 taken 792649 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 60973 times.
✓ Branch 3 taken 731676 times.
✓ Branch 4 taken 506 times.
✓ Branch 5 taken 60467 times.
✓ Branch 6 taken 378 times.
✓ Branch 7 taken 128 times.
792649 if (p > 0 && (p%13)==12 && (i < (newpoSPRITE-oldpdTOTAL) || (s_version >= 4))) //It's > 0 instead of >= 0 because it should append
18425 {
18426
1/2
✓ Branch 0 taken 60845 times.
✗ Branch 1 not taken.
60845 if (s_version < 5) //Bumping up the size of level palettes
18427 {
18428 60845 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18429 60845 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18430 60845 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18431 60845 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18432 60845 q+=4;
18433 60845 }
18434 else
18435 {
18436 for(int m = 0; m < 4; ++m)
18437 {
18438 memset(temp_colordata, 0, 48);
18439 if(!pfread(temp_colordata,48,f))
18440 {
18441 return qe_invalid;
18442 }
18443 memcpy(&colordata[q*48], temp_colordata, 48);
18444 ++q;
18445 }
18446 }
18447 60845 }
18448 792649 ++p;
18449 792649 }
18450
18451
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 189 times.
254 if(s_version < 4)
18452 {
18453
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 64 times.
65 if (!should_skip)
18454 {
18455 64 memcpy(colordata+(poSPRITE255*48), colordata+((q-30)*48), 30*16*3);
18456 64 memset(colordata+((q-30)*48), 0, ((poSPRITE255-(q-30))*48));
18457 64 }
18458 65 }
18459 else
18460 {
18461
2/2
✓ Branch 0 taken 628992 times.
✓ Branch 1 taken 189 times.
629181 for(int32_t i=0; i<newerpdTOTAL-newpdTOTAL; ++i)
18462 {
18463
1/2
✓ Branch 0 taken 628992 times.
✗ Branch 1 not taken.
628992 if(!pfread(temp_colordata,48,f))
18464 {
18465 return qe_invalid;
18466 }
18467
18468
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 628992 times.
628992 if (should_skip)
18469 continue;
18470
18471 628992 memcpy(&colordata[q*48], temp_colordata, 48);
18472 628992 ++q;
18473
5/6
✓ Branch 0 taken 628992 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 48384 times.
✓ Branch 3 taken 580608 times.
✓ Branch 4 taken 378 times.
✓ Branch 5 taken 48006 times.
628992 if (p > 0 && (p%13)==12 && i < newerpoSPRITE-newpdTOTAL) //It's > 0 instead of >= 0 because it should append
18474 {
18475
1/2
✓ Branch 0 taken 48006 times.
✗ Branch 1 not taken.
48006 if (s_version < 5) //Bumping up the size of level palettes
18476 {
18477 48006 memcpy(&colordata[(q)*48], &colordata[1*48], 48);
18478 48006 memcpy(&colordata[(q+1)*48], &colordata[5*48], 48);
18479 48006 memcpy(&colordata[(q+2)*48], &colordata[7*48], 48);
18480 48006 memcpy(&colordata[(q+3)*48], &colordata[8*48], 48);
18481 48006 q+=4;
18482 48006 }
18483 else
18484 {
18485 for(int m = 0; m < 4; ++m)
18486 {
18487 memset(temp_colordata, 0, 48);
18488 if(!pfread(temp_colordata,48,f))
18489 {
18490 return qe_invalid;
18491 }
18492 memcpy(&colordata[q*48], temp_colordata, 48);
18493 ++q;
18494 }
18495 }
18496 48006 }
18497 628992 ++p;
18498 628992 }
18499
18500 //By this point, q should be about equal to pdTOTAL255. If it isn't, I've fucked up. -Deedee
18501 }
18502 }
18503 272 }
18504 else
18505 {
18506
2/2
✓ Branch 0 taken 3700827 times.
✓ Branch 1 taken 423 times.
3701250 for(int32_t i=0; i<pdTOTAL255; ++i)
18507 {
18508 3700827 memset(temp_colordata, 0, 48);
18509
18510
1/2
✓ Branch 0 taken 3700827 times.
✗ Branch 1 not taken.
3700827 if(!pfread(temp_colordata,48,f))
18511 {
18512 return qe_invalid;
18513 }
18514
18515 3700827 memcpy(&colordata[i*48], temp_colordata, 48);
18516 3700827 }
18517 }
18518
18519
4/4
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 1 times.
✓ Branch 2 taken 38 times.
✓ Branch 3 taken 656 times.
695 if (!should_skip && s_version < 6)
18520 {
18521
2/2
✓ Branch 0 taken 275488512 times.
✓ Branch 1 taken 656 times.
275489168 for (int i = 0; i < psTOTAL255; i++)
18522 {
18523 275488512 colordata[i] = _rgb_scale_6[colordata[i]];
18524 275488512 }
18525 656 }
18526
18527
5/6
✓ Branch 0 taken 677 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 671 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 6 times.
695 if((version < 0x192)||((version == 0x192)&&(build<76)))
18528 {
18529
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18 times.
18 if (!should_skip)
18530 18 init_palnames();
18531 18 }
18532 else
18533 {
18534 677 int32_t palnamestoread = 0;
18535
18536
2/2
✓ Branch 0 taken 65 times.
✓ Branch 1 taken 612 times.
677 if(s_version < 3)
18537 65 palnamestoread = OLDMAXLEVELS;
18538 else
18539 612 palnamestoread = 512;
18540
18541
2/2
✓ Branch 0 taken 329984 times.
✓ Branch 1 taken 677 times.
330661 for(int32_t i=0; i<palnamestoread; ++i)
18542 {
18543
1/2
✓ Branch 0 taken 329984 times.
✗ Branch 1 not taken.
329984 if(!p_getstr(temp_palname,PALNAMESIZE,f))
18544 {
18545 return qe_invalid;
18546 }
18547
18548
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 329728 times.
329984 if (!should_skip)
18549 329728 memcpy(palnames[i], temp_palname, PALNAMESIZE);
18550 329984 }
18551
18552
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 676 times.
677 if (should_skip)
18553 1 return 0;
18554
18555
2/2
✓ Branch 0 taken 16384 times.
✓ Branch 1 taken 676 times.
17060 for(int32_t i=palnamestoread; i<MAXLEVELS; i++)
18556 {
18557 16384 memset(palnames[i], 0, PALNAMESIZE);
18558 16384 }
18559 }
18560
18561
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 671 times.
694 if(version > 0x192)
18562 {
18563
2/2
✓ Branch 0 taken 171776 times.
✓ Branch 1 taken 671 times.
172447 for(int32_t i=0; i<256; i++)
18564 {
18565
2/2
✓ Branch 0 taken 515328 times.
✓ Branch 1 taken 171776 times.
687104 for(int32_t j=0; j<3; j++)
18566 {
18567 515328 temp_misc.cycles[i][j].first=0;
18568 515328 temp_misc.cycles[i][j].count=0;
18569 515328 temp_misc.cycles[i][j].speed=0;
18570 515328 }
18571 171776 }
18572
18573
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&palcycles,f))
18574 {
18575 return qe_invalid;
18576 }
18577
18578
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if (palcycles > NUM_PAL_CYCLES)
18579 {
18580 return qe_invalid;
18581 }
18582
18583
2/2
✓ Branch 0 taken 15342 times.
✓ Branch 1 taken 671 times.
16013 for(int32_t i=0; i<palcycles; i++)
18584 {
18585
2/2
✓ Branch 0 taken 46026 times.
✓ Branch 1 taken 15342 times.
61368 for(int32_t j=0; j<3; j++)
18586 {
18587
1/2
✓ Branch 0 taken 46026 times.
✗ Branch 1 not taken.
46026 if(!p_getc(&temp_misc.cycles[i][j].first,f))
18588 {
18589 return qe_invalid;
18590 }
18591 46026 }
18592
18593
2/2
✓ Branch 0 taken 46026 times.
✓ Branch 1 taken 15342 times.
61368 for(int32_t j=0; j<3; j++)
18594 {
18595
1/2
✓ Branch 0 taken 46026 times.
✗ Branch 1 not taken.
46026 if(!p_getc(&temp_misc.cycles[i][j].count,f))
18596 {
18597 return qe_invalid;
18598 }
18599 46026 }
18600
18601
2/2
✓ Branch 0 taken 46026 times.
✓ Branch 1 taken 15342 times.
61368 for(int32_t j=0; j<3; j++)
18602 {
18603
1/2
✓ Branch 0 taken 46026 times.
✗ Branch 1 not taken.
46026 if(!p_getc(&temp_misc.cycles[i][j].speed,f))
18604 {
18605 return qe_invalid;
18606 }
18607 46026 }
18608 15342 }
18609
18610 671 memcpy(Misc, &temp_misc, sizeof(temp_misc));
18611 671 }
18612
18613 694 return 0;
18614 695 }
18615
18616 695 int32_t readtiles(PACKFILE *f, tiledata *buf, zquestheader *Header, word version, word build, word start_tile, int32_t max_tiles, bool from_init)
18617 {
18618
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_tiles);
18619
18620 695 int32_t tiles_used=0;
18621 695 word section_version = 0;
18622 695 word section_cversion = 0;
18623 695 int32_t section_size= 0;
18624 695 byte *temp_tile = new byte[tilesize(tf32Bit)];
18625
18626 //Tile Expansion
18627 //if ( version >= 0x254 && build >= 41 )
18628
4/4
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 423 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 266 times.
695 if (version < 0x254 && build < 41)
18629 {
18630 266 max_tiles = ZC250MAXTILES;
18631 266 }
18632
18633
18634
2/6
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 695 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
695 if(Header!=NULL&&(!Header->data_flags[ZQ_TILES]&&!from_init)) //keep for old quests
18635 {
18636 if(!init_tiles(true, Header))
18637 {
18638 al_trace("Unable to initialize tiles\n");
18639 }
18640
18641 delete[] temp_tile;
18642 temp_tile=NULL;
18643 return 0;
18644 }
18645 else
18646 {
18647
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 671 times.
695 if(version > 0x192)
18648 {
18649 //section version info
18650
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&section_version,f))
18651 {
18652 delete[] temp_tile;
18653 return qe_invalid;
18654 }
18655
18656 671 FFCore.quest_format[vTiles] = section_version;
18657
18658
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&section_cversion,f))
18659 {
18660 delete[] temp_tile;
18661 return qe_invalid;
18662 }
18663
18664 //section size
18665
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&section_size,f))
18666 {
18667 delete[] temp_tile;
18668 return qe_invalid;
18669 }
18670 671 }
18671
18672 //if ( build < 41 )
18673 //{
18674 // tiles_used = ZC250MAXTILES;
18675 //}
18676
18677
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 if(version < 0x174)
18678 {
18679 tiles_used=TILES_PER_PAGE*4;
18680 } //no expanded tile space
18681
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 677 times.
695 else if(version < 0x191)
18682 {
18683 18 tiles_used=OLDMAXTILES;
18684 18 }
18685 else
18686 {
18687 //finally... section data
18688
3/4
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 254 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
677 if ( version >= 0x254 && build >= 41 ) //read and write the size of tiles_used properly
18689 {
18690
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 if(!p_igetl(&tiles_used,f))
18691 {
18692 delete[] temp_tile;
18693 return qe_invalid;
18694 }
18695 423 }
18696 else
18697 {
18698
1/2
✓ Branch 0 taken 254 times.
✗ Branch 1 not taken.
254 if(!p_igetw(&tiles_used,f))
18699 {
18700 delete[] temp_tile;
18701 return qe_invalid;
18702 }
18703 }
18704 }
18705
18706
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 tiles_used=zc_min(tiles_used, max_tiles);
18707
18708 //if ( version < 0x254 || ( version >= 0x254 && build < 41 )) //don't do this, it crashes ZQuest. -Z
18709 //if ( version < 0x254 && build < 41 )
18710
3/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 272 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 423 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
695 if ( version < 0x254 || (version == 0x254 && build < 41) )
18711 //if ( build < 41 )
18712 {
18713
1/2
✓ Branch 0 taken 272 times.
✗ Branch 1 not taken.
272 tiles_used=zc_min(tiles_used, ZC250MAXTILES-start_tile);
18714 272 }
18715 else //2.55
18716 {
18717
1/2
✓ Branch 0 taken 423 times.
✗ Branch 1 not taken.
423 tiles_used = zc_min(tiles_used,NEWMAXTILES-start_tile);
18718 }
18719
18720 //if ( section_version > 1 ) tiles_used = NEWMAXTILES;
18721
18722
18723
2/2
✓ Branch 0 taken 28425391 times.
✓ Branch 1 taken 695 times.
28426086 for(int32_t i=0; i<tiles_used; ++i)
18724 {
18725 28425391 byte format=tf4Bit;
18726 28425391 memset(temp_tile, 0, tilesize(tf32Bit));
18727
18728
3/6
✓ Branch 0 taken 2985456 times.
✓ Branch 1 taken 25439935 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 2985456 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
28425391 if((version>0x211)||((version==0x211)&&(build>4)))
18729 {
18730
1/2
✓ Branch 0 taken 25439935 times.
✗ Branch 1 not taken.
25439935 if(!p_getc(&format,f))
18731 {
18732 delete[] temp_tile;
18733 return qe_invalid;
18734 }
18735 25439935 }
18736
4/4
✓ Branch 0 taken 18222800 times.
✓ Branch 1 taken 10202591 times.
✓ Branch 2 taken 8323020 times.
✓ Branch 3 taken 9899780 times.
28425391 if(section_version > 2 && !format)
18737 {
18738 9899780 reset_tile(buf,start_tile+i,tf4Bit);
18739 9899780 continue;
18740 }
18741
18742
2/2
✓ Branch 0 taken 18012104 times.
✓ Branch 1 taken 513507 times.
18525611 int size = format == tf4Bit ? 128 : tilesize(format);
18743
1/2
✓ Branch 0 taken 18525611 times.
✗ Branch 1 not taken.
18525611 if(!pfread(temp_tile,size,f))
18744 {
18745 delete[] temp_tile;
18746 return qe_invalid;
18747 }
18748
18749
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 18525611 times.
18525611 if (should_skip)
18750 continue;
18751
18752 18525611 buf[start_tile+i].format=format;
18753
18754
2/2
✓ Branch 0 taken 18354467 times.
✓ Branch 1 taken 171144 times.
18525611 if(buf[start_tile+i].data)
18755 {
18756 18354467 free(buf[start_tile+i].data);
18757 18354467 buf[start_tile+i].data=NULL;
18758 18354467 }
18759
18760 18525611 buf[start_tile+i].data=(byte *)malloc(tilesize(buf[start_tile+i].format));
18761
18762
2/2
✓ Branch 0 taken 18012104 times.
✓ Branch 1 taken 513507 times.
18525611 if (format == tf4Bit)
18763 {
18764 byte temp[256];
18765 18012104 byte *si = temp_tile + 128;
18766 18012104 byte *di = temp + 256;
18767
18768
2/2
✓ Branch 0 taken 2305549312 times.
✓ Branch 1 taken 18012104 times.
2323561416 for(int i=127; i>=0; --i)
18769 {
18770 2305549312 (*(--di)) = (*(--si)) >> 4;
18771 2305549312 (*(--di)) = (*si) & 15;
18772 2305549312 }
18773
18774 18012104 memcpy(buf[start_tile+i].data,temp,256);
18775 18012104 }
18776 else
18777 {
18778 513507 memcpy(buf[start_tile+i].data,temp_tile,tilesize(buf[start_tile+i].format));
18779 }
18780 18525611 }
18781 }
18782
18783
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 if (should_skip)
18784 return 0;
18785
18786
2/2
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 272 times.
695 if ( section_version < 2 ) //write blank tile data --check s_version with this again instead?
18787 {
18788
2/2
✓ Branch 0 taken 40522560 times.
✓ Branch 1 taken 272 times.
40522832 for ( int32_t q = ZC250MAXTILES; q < NEWMAXTILES; ++q )
18789 {
18790
18791 //memcpy(buf[q].data,temp_tile,tilesize(buf[q].format));
18792 40522560 reset_tile(buf,q,tf4Bit);
18793
18794
18795 /*
18796
18797 byte tempbyte;
18798 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18799 {
18800 tempbyte=buf[ZC250MAXTILES-1].data[i];
18801 buf[q].data[i] = tempbyte;
18802 }
18803 //int32_t temp = tempbyte=buf[130].data[i];
18804 //buf[q].data = buf[ZC250MAXTILES-1].data;
18805 */
18806 //reset_tile(buf,q,tf4Bit);
18807 40522560 }
18808
18809 272 }
18810
18811
4/6
✓ Branch 0 taken 423 times.
✓ Branch 1 taken 272 times.
✓ Branch 2 taken 423 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✓ Branch 5 taken 423 times.
695 if ( version < 0x254 || ( version >= 0x254 && build < 41 ))
18812 {
18813
2/2
✓ Branch 0 taken 9086445 times.
✓ Branch 1 taken 272 times.
9086717 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18814 {
18815 9086445 reset_tile(buf,i,tf4Bit);
18816 9086445 }
18817 272 }
18818 else
18819 {
18820
2/2
✓ Branch 0 taken 71936984 times.
✓ Branch 1 taken 423 times.
71937407 for(int32_t i=start_tile+tiles_used; i<max_tiles; ++i)
18821 {
18822 71936984 reset_tile(buf,i,tf4Bit);
18823 71936984 }
18824 }
18825
18826
5/6
✓ Branch 0 taken 677 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 671 times.
✓ Branch 4 taken 6 times.
✗ Branch 5 not taken.
695 if((version < 0x192)|| ((version == 0x192)&&(build<186)))
18827 {
18828
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 6 times.
24 if(get_qr(qr_BSZELDA)) //
18829 {
18830 byte tempbyte;
18831 6 int32_t floattile=wpnsbuf[iwSwim].tile;
18832
18833
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++) //BSZelda tiles are out of order //does this include swim tiles?
18834 {
18835 1536 tempbyte=buf[23].data[i];
18836 1536 buf[23].data[i]=buf[24].data[i];
18837 1536 buf[24].data[i]=buf[25].data[i];
18838 1536 buf[25].data[i]=buf[26].data[i];
18839 1536 buf[26].data[i]=tempbyte;
18840 1536 }
18841 //swim tiles are out of order, too, but nobody cared? -Z
18842
2/2
✓ Branch 0 taken 1536 times.
✓ Branch 1 taken 6 times.
1542 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18843 {
18844 1536 tempbyte=buf[floattile+11].data[i];
18845 1536 buf[floattile+11].data[i]=buf[floattile+12].data[i];
18846 1536 buf[floattile+12].data[i]=tempbyte;
18847 1536 }
18848 6 }
18849 24 }
18850
18851
3/6
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 83 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 612 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
695 if((version < 0x211)||((version == 0x211)&&(build<7))) //Goriya tiles are out of order
18852 {
18853
2/2
✓ Branch 0 taken 61 times.
✓ Branch 1 taken 22 times.
83 if(!get_qr(qr_NEWENEMYTILES))
18854 {
18855 byte tempbyte;
18856
18857
2/2
✓ Branch 0 taken 5632 times.
✓ Branch 1 taken 22 times.
5654 for(int32_t i=0; i<tilesize(tf4Bit); i++)
18858 {
18859 5632 tempbyte=buf[130].data[i];
18860 5632 buf[130].data[i]=buf[132].data[i];
18861 5632 buf[132].data[i]=tempbyte;
18862
18863 5632 tempbyte=buf[131].data[i];
18864 5632 buf[131].data[i]=buf[133].data[i];
18865 5632 buf[133].data[i]=tempbyte;
18866 5632 }
18867 22 }
18868 83 }
18869
18870 695 al_trace("Registering blank tiles\n");
18871 695 register_blank_tiles();
18872
18873 //memset(temp_tile, 0, tilesize(tf32Bit));
18874
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 delete[] temp_tile;
18875 695 temp_tile=NULL;
18876 695 return 0;
18877 695 }
18878
18879 694 int32_t readtunes(PACKFILE *f, zquestheader *Header, zctune *tunes /*zcmidi_ *midis*/)
18880 {
18881
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 23 times.
694 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_midis);
18882
18883 static byte fake_midi_flags[32];
18884
18885
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
694 byte *mf=should_skip ? fake_midi_flags : midi_flags;
18886 int32_t dummy;
18887 word dummy2;
18888 // zcmidi_ temp_midi;
18889 int32_t tunes_to_read;
18890 694 int32_t tune_count=0;
18891 694 word section_version=0;
18892 694 zctune temp;
18893
18894
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 671 times.
694 if(Header->zelda_version < 0x193)
18895 {
18896 // mf=Header->data_flags+ZQ_MIDIS2;
18897
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
23 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<178)))
18898 {
18899 22 tunes_to_read=MAXCUSTOMMIDIS192b177;
18900 22 }
18901 else
18902 {
18903 1 tunes_to_read=MAXCUSTOMTUNES;
18904 }
18905 23 }
18906 else
18907 {
18908 //section version info
18909
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&section_version,f))
18910 {
18911 return qe_invalid;
18912 }
18913
18914
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if (!should_skip)
18915 671 FFCore.quest_format[vMIDIs] = section_version;
18916
18917
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&dummy2,f))
18918 {
18919 return qe_invalid;
18920 }
18921
18922 //section size
18923
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&dummy,f))
18924 {
18925 return qe_invalid;
18926 }
18927
18928 //finally... section data
18929
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!pfread(midi_flags,sizeof(midi_flags),f))
18930 {
18931 return qe_invalid;
18932 }
18933
18934 671 tunes_to_read=MAXCUSTOMTUNES;
18935 }
18936
18937
2/2
✓ Branch 0 taken 174888 times.
✓ Branch 1 taken 694 times.
175582 for(int32_t i=0; i<MAXCUSTOMTUNES; ++i)
18938 {
18939
2/2
✓ Branch 0 taken 10243 times.
✓ Branch 1 taken 164645 times.
174888 if(get_bit(mf, i))
18940 {
18941 10243 ++tune_count;
18942 10243 }
18943 174888 }
18944
18945
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
694 if (!should_skip)
18946 694 reset_tunes(tunes); //reset_midis(midis);
18947
18948
2/2
✓ Branch 0 taken 170048 times.
✓ Branch 1 taken 694 times.
170742 for(int32_t i=0; i<tunes_to_read; i++)
18949 {
18950 170048 temp.clear(); //memset(&temp_midi,0,sizeof(zcmidi_));
18951
18952
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 170048 times.
170048 if (!should_skip)
18953 170048 tunes[i].reset(); // reset_midi(midis+i);
18954
18955
2/2
✓ Branch 0 taken 159805 times.
✓ Branch 1 taken 10243 times.
170048 if(get_bit(mf,i))
18956 {
18957
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7580 times.
10243 if(section_version < 4)
18958 {
18959
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if(!p_getstr(temp.title,20,f))
18960 {
18961 return qe_invalid;
18962 }
18963 2663 }
18964 else
18965 {
18966
1/2
✓ Branch 0 taken 7580 times.
✗ Branch 1 not taken.
7580 if(!p_getstr(temp.title,sizeof(temp.title)-1,f))
18967 {
18968 return qe_invalid;
18969 }
18970 }
18971
18972
1/2
✓ Branch 0 taken 10243 times.
✗ Branch 1 not taken.
10243 if(!p_igetl(&temp.start,f))
18973 {
18974 return qe_invalid;
18975 }
18976
18977
1/2
✓ Branch 0 taken 10243 times.
✗ Branch 1 not taken.
10243 if(!p_igetl(&temp.loop_start,f))
18978 {
18979 return qe_invalid;
18980 }
18981
18982
1/2
✓ Branch 0 taken 10243 times.
✗ Branch 1 not taken.
10243 if(!p_igetl(&temp.loop_end,f))
18983 {
18984 return qe_invalid;
18985 }
18986
18987
1/2
✓ Branch 0 taken 10243 times.
✗ Branch 1 not taken.
10243 if(!p_igetw(&temp.loop,f))
18988 {
18989 return qe_invalid;
18990 }
18991
18992
1/2
✓ Branch 0 taken 10243 times.
✗ Branch 1 not taken.
10243 if(!p_igetw(&temp.volume,f))
18993 {
18994 return qe_invalid;
18995 }
18996
18997
2/2
✓ Branch 0 taken 9994 times.
✓ Branch 1 taken 249 times.
10243 if(Header->zelda_version < 0x193)
18998 {
18999
1/2
✓ Branch 0 taken 249 times.
✗ Branch 1 not taken.
249 if(!p_igetl(&dummy,f))
19000 {
19001 return qe_invalid;
19002 }
19003 249 }
19004
19005
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7580 times.
10243 if(section_version >= 3)
19006 {
19007
1/2
✓ Branch 0 taken 7580 times.
✗ Branch 1 not taken.
7580 if(!pfread(&temp.flags,sizeof(temp.flags),f))
19008 {
19009 return qe_invalid;
19010 }
19011 7580 }
19012
19013
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 10243 times.
10243 if (!should_skip)
19014 10243 tunes[i].copyfrom(temp); // memcpy(&midis[i], &temp_midi, sizeof(zcmidi_));
19015
19016
2/2
✓ Branch 0 taken 2663 times.
✓ Branch 1 taken 7580 times.
10243 if(section_version < 2) //= 1 || (Header->zelda_version < 0x211) || (Header->zelda_version == 0x211 && Header->build < 18))
19017 {
19018
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 2663 times.
2663 if (should_skip)
19019 {
19020 if (read_midi(f)==NULL)
19021 {
19022 return qe_invalid;
19023 }
19024
19025 continue;
19026 }
19027
19028 // old format - a midi is a midi
19029
1/2
✓ Branch 0 taken 2663 times.
✗ Branch 1 not taken.
2663 if((tunes[i].data=read_midi(f))==NULL)
19030 {
19031 return qe_invalid;
19032 }
19033
19034 //yes you can do this. Isn't the ? operator awesome? :)
19035 2663 tunes[i].format = MFORMAT_MIDI;
19036 2663 }
19037 else
19038 {
19039 // 'midi' could be midi or nes, gb, ... music
19040
1/2
✓ Branch 0 taken 7580 times.
✗ Branch 1 not taken.
7580 if(!pfread(&tunes[i].format,sizeof(tunes[i].format),f))
19041 {
19042 return qe_invalid;
19043 }
19044
19045 7580 zctune *ptr = &tunes[i];
19046
19047
1/2
✓ Branch 0 taken 7580 times.
✗ Branch 1 not taken.
7580 switch(temp.format)
19048 {
19049 case MFORMAT_MIDI:
19050
1/2
✓ Branch 0 taken 7580 times.
✗ Branch 1 not taken.
7580 if((ptr->data=read_midi(f))==NULL)
19051 {
19052 return qe_invalid;
19053 }
19054
19055 7580 break;
19056
19057 default:
19058 return qe_invalid;
19059 break;
19060 }
19061 }
19062 10243 }
19063 170048 }
19064
19065 694 return 0;
19066 694 }
19067
19068 694 int32_t readcheatcodes(PACKFILE *f, zquestheader *Header)
19069 {
19070
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 23 times.
694 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_cheats);
19071
19072 int32_t dummy;
19073 ZCHEATS tempzcheats;
19074 694 char temp_use_cheats=1;
19075 694 memset(&tempzcheats, 0, sizeof(tempzcheats));
19076 694 word s_version = 0;
19077
19078
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 671 times.
694 if(Header->zelda_version > 0x192)
19079 {
19080 //section version info
19081
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&s_version,f))
19082 {
19083 return qe_invalid;
19084 }
19085
19086 671 FFCore.quest_format[vCheats] = s_version;
19087
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetw(&dummy,f))
19088 {
19089 return qe_invalid;
19090 }
19091
19092 //section size
19093
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_igetl(&dummy,f))
19094 {
19095 return qe_invalid;
19096 }
19097
19098 //finally... section data
19099
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(!p_getc(&temp_use_cheats,f))
19100 {
19101 return qe_invalid;
19102 }
19103 671 }
19104
19105
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
694 if(Header->data_flags[ZQ_CHEATS2])
19106 {
19107
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 if(!p_igetl(&tempzcheats.flags,f))
19108 {
19109 return qe_invalid;
19110 }
19111
19112
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 if(!pfread(&tempzcheats.codes, sizeof(tempzcheats.codes),f))
19113 {
19114 return qe_invalid;
19115 }
19116 694 }
19117
19118
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
694 if (should_skip)
19119 return 0;
19120
19121 694 memcpy(&zcheats, &tempzcheats, sizeof(tempzcheats));
19122 694 Header->data_flags[ZQ_CHEATS2]=temp_use_cheats;
19123
19124 694 return 0;
19125 694 }
19126
19127 289 int32_t readinitdata_old(PACKFILE *f, zquestheader *Header, word s_version, word s_cversion, zinitdata& temp_zinit)
19128 {
19129
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 266 times.
289 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
19130
19131 int32_t dummy;
19132 byte padding, tempbyte;
19133
19134 // Legacy item properties (now integrated into itemdata)
19135 byte sword_hearts[4];
19136 byte beam_hearts[4];
19137 289 byte beam_percent=0;
19138 word beam_power[4];
19139 289 byte hookshot_length=99;
19140 289 byte hookshot_links=100;
19141 289 byte longshot_length=99;
19142 289 byte longshot_links=100;
19143 289 byte moving_fairy_hearts=3;
19144 289 byte moving_fairy_heart_percent=0;
19145 289 byte stationary_fairy_hearts=3;
19146 289 byte stationary_fairy_heart_percent=0;
19147 289 byte moving_fairy_magic=0;
19148 289 byte moving_fairy_magic_percent=0;
19149 289 byte stationary_fairy_magic=0;
19150 289 byte stationary_fairy_magic_percent=0;
19151 289 byte blue_potion_hearts=100;
19152 289 byte blue_potion_heart_percent=1;
19153 289 byte red_potion_hearts=100;
19154 289 byte red_potion_heart_percent=1;
19155 289 byte blue_potion_magic=100;
19156 289 byte blue_potion_magic_percent=1;
19157 289 byte red_potion_magic=100;
19158 289 byte red_potion_magic_percent=1;
19159
19160 289 byte bomb_ratio = 4;
19161
19162 289 subscr_mode = 0;
19163
19164 /* HIGHLY UNORTHODOX UPDATING THING, by L
19165 * This fixes quests made before revision 277 (such as the 'Lost Isle Build'),
19166 * where the speed of Pols Voice changed. It also coincided with V_INITDATA
19167 * changing from 13 to 14.
19168 */
19169
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
289 if(s_version < 14)
19170 82 fixpolsvoice=true;
19171
19172 /* End highly unorthodox updating thing */
19173
19174
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 95 times.
✓ Branch 3 taken 112 times.
289 if(s_version >= 15 && get_bit(deprecated_rules, 27)) // The int16_t-lived rule, qr_JUMPHEROLAYER3
19175 112 temp_zinit.jump_hero_layer_threshold=0;
19176
19177
2/2
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 207 times.
289 if(s_version >= 10)
19178 {
19179 char temp;
19180
19181 //new-style items
19182
2/2
✓ Branch 0 taken 52992 times.
✓ Branch 1 taken 207 times.
53199 for(int32_t j=0; j<256; j++)
19183 {
19184
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 52992 times.
52992 if(!p_getc(&temp,f))
19185 return qe_invalid;
19186
19187 52992 temp_zinit.set_item(j, temp != 0);
19188 52992 }
19189 207 }
19190
19191
5/6
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 18 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
289 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>26)))
19192 {
19193 char temp;
19194
19195 //finally... section data
19196
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
276 if((Header->zelda_version > 0x192)||
19197 //new only
19198
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19199 {
19200 //OLD-style items... sigh
19201
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 60 times.
267 if(s_version < 10)
19202 {
19203
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19204 {
19205 return qe_invalid;
19206 }
19207
19208 60 temp_zinit.set_item(iRaft, temp != 0);
19209
19210
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19211 {
19212 return qe_invalid;
19213 }
19214
19215 60 temp_zinit.set_item(iLadder, temp != 0);
19216
19217
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19218 {
19219 return qe_invalid;
19220 }
19221
19222 60 temp_zinit.set_item(iBook, temp != 0);
19223
19224
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19225 {
19226 return qe_invalid;
19227 }
19228
19229 60 temp_zinit.set_item(iMKey, temp != 0);
19230
19231
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19232 {
19233 return qe_invalid;
19234 }
19235
19236 60 temp_zinit.set_item(iFlippers, temp != 0);
19237
19238
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19239 {
19240 return qe_invalid;
19241 }
19242
19243 60 temp_zinit.set_item(iBoots, temp != 0);
19244 60 }
19245 267 }
19246
19247
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
271 if(s_version < 10)
19248 {
19249 char tempring, tempsword, tempshield, tempwallet, tempbracelet, tempamulet, tempbow;
19250
19251
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempring,f))
19252 {
19253 return qe_invalid;
19254 }
19255
19256
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempsword,f))
19257 {
19258 return qe_invalid;
19259 }
19260
19261
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempshield,f))
19262 {
19263 return qe_invalid;
19264 }
19265
19266
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwallet,f))
19267 {
19268 return qe_invalid;
19269 }
19270
19271
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbracelet,f))
19272 {
19273 return qe_invalid;
19274 }
19275
19276
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempamulet,f))
19277 {
19278 return qe_invalid;
19279 }
19280
19281
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempbow,f))
19282 {
19283 return qe_invalid;
19284 }
19285
19286 //old only
19287
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19288 {
19289
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempring=(tempring)?(1<<(tempring-1)):0;
19290
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempsword=(tempsword)?(1<<(tempsword-1)):0;
19291
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 tempshield=(tempshield)?(1<<(tempshield-1)):0;
19292
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwallet=(tempwallet)?(1<<(tempwallet-1)):0;
19293
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbracelet=(tempbracelet)?(1<<(tempbracelet-1)):0;
19294
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempamulet=(tempamulet)?(1<<(tempamulet-1)):0;
19295
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempbow=(tempbow)?(1<<(tempbow-1)):0;
19296 4 }
19297
19298 //rings start at level 2... wtf
19299 //account for this -DD
19300 64 tempring <<= 1;
19301 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_ring, tempring);
19302 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_sword, tempsword);
19303 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_shield, tempshield);
19304 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, tempwallet);
19305 //bracelet ALSO starts at level 2 :-( -DD
19306 64 tempbracelet<<=1;
19307 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bracelet, tempbracelet);
19308 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_amulet, tempamulet);
19309 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bow, tempbow);
19310
19311 //new only
19312
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
64 if((Header->zelda_version == 0x192)&&(Header->build>173))
19313 {
19314
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19315 {
19316
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19317 {
19318 return qe_invalid;
19319 }
19320 32 }
19321 1 }
19322
19323 char tempcandle, tempboomerang, temparrow, tempwhistle;
19324
19325
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempcandle,f))
19326 {
19327 return qe_invalid;
19328 }
19329
19330
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempboomerang,f))
19331 {
19332 return qe_invalid;
19333 }
19334
19335
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temparrow,f))
19336 {
19337 return qe_invalid;
19338 }
19339
19340
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temp,f))
19341 {
19342 return qe_invalid;
19343 }
19344
19345 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_potion, temp);
19346
19347
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempwhistle,f))
19348 {
19349 return qe_invalid;
19350 }
19351
19352 //old only
19353
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
64 if((Header->zelda_version == 0x192)&&(Header->build<174))
19354 {
19355
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempcandle=(tempcandle)?(1<<(tempcandle-1)):0;
19356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempboomerang=(tempboomerang)?(1<<(tempboomerang-1)):0;
19357
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 temparrow=(temparrow)?(1<<(temparrow-1)):0;
19358
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 4 times.
4 tempwhistle=(tempwhistle)?(1<<(tempwhistle-1)):0;
19359 4 }
19360
19361 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_candle, tempcandle);
19362 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_brang, tempboomerang);
19363 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_arrow, temparrow);
19364 64 addOldStyleFamily(&temp_zinit, itemsbuf, itype_whistle, tempwhistle);
19365 //What about the potion...?
19366
19367 64 }
19368
19369
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 253 times.
271 if(s_version < 29)
19370 {
19371 //Oh sure, stick these IN THE MIDDLE OF THE ITEMS, just to make me want
19372 //to jab out my eye...
19373
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!p_getc(&padding,f))
19374 return qe_invalid;
19375 253 temp_zinit.counter[crBOMBS] = padding;
19376
19377
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!p_getc(&padding,f))
19378 return qe_invalid;
19379 253 temp_zinit.counter[crSBOMBS] = padding;
19380 253 }
19381
19382 //Back to more OLD item code
19383
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
271 if(s_version < 10)
19384 {
19385
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 59 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
69 if((Header->zelda_version > 0x192)||
19386 //new only
19387
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19388 {
19389
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19390 {
19391 return qe_invalid;
19392 }
19393
19394 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_wand, temp);
19395
19396
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19397 {
19398 return qe_invalid;
19399 }
19400
19401 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_letter, temp);
19402
19403
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19404 {
19405 return qe_invalid;
19406 }
19407
19408 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_lens, temp);
19409
19410
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19411 {
19412 return qe_invalid;
19413 }
19414
19415 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hookshot, temp);
19416
19417
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19418 {
19419 return qe_invalid;
19420 }
19421
19422 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_bait, temp);
19423
19424
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19425 {
19426 return qe_invalid;
19427 }
19428
19429 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_hammer, temp);
19430
19431
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19432 {
19433 return qe_invalid;
19434 }
19435
19436 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divinefire, temp);
19437
19438
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19439 {
19440 return qe_invalid;
19441 }
19442
19443 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineescape, temp);
19444
19445
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19446 {
19447 return qe_invalid;
19448 }
19449
19450 60 addOldStyleFamily(&temp_zinit, itemsbuf, itype_divineprotection, temp);
19451
19452
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&temp,f))
19453 {
19454 return qe_invalid;
19455 }
19456
19457
2/2
✓ Branch 0 taken 59 times.
✓ Branch 1 taken 1 times.
60 if(Header->zelda_version == 0x192)
19458 {
19459
2/2
✓ Branch 0 taken 32 times.
✓ Branch 1 taken 1 times.
33 for(int32_t q=0; q<32; q++)
19460 {
19461
1/2
✓ Branch 0 taken 32 times.
✗ Branch 1 not taken.
32 if(!p_getc(&padding,f))
19462 {
19463 return qe_invalid;
19464 }
19465 32 }
19466 1 }
19467 60 }
19468 64 }
19469
19470 //old only
19471
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
271 if((Header->zelda_version == 0x192)&&(Header->build<174))
19472 {
19473 byte equipment, tmpitm; //bit flags
19474
19475
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&equipment,f))
19476 {
19477 return qe_invalid;
19478 }
19479
19480 4 temp_zinit.set_item(iRaft, get_bit(&equipment, idE_RAFT)!=0);
19481 4 temp_zinit.set_item(iLadder, get_bit(&equipment, idE_LADDER)!=0);
19482 4 temp_zinit.set_item(iBook, get_bit(&equipment, idE_BOOK)!=0);
19483 4 temp_zinit.set_item(iMKey, get_bit(&equipment, idE_KEY)!=0);
19484 4 temp_zinit.set_item(iFlippers, get_bit(&equipment, idE_FLIPPERS)!=0);
19485 4 temp_zinit.set_item(iBoots, get_bit(&equipment, idE_BOOTS)!=0);
19486
19487
19488
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&tmpitm,f))
19489 {
19490 return qe_invalid;
19491 }
19492
19493 4 temp_zinit.set_item(iWand, get_bit(&tmpitm, idI_WAND)!=0);
19494 4 temp_zinit.set_item(iLetter, get_bit(&tmpitm, idI_LETTER)!=0);
19495 4 temp_zinit.set_item(iLens, get_bit(&tmpitm, idI_LENS)!=0);
19496 4 temp_zinit.set_item(iHookshot, get_bit(&tmpitm, idI_HOOKSHOT)!=0);
19497 4 temp_zinit.set_item(iBait, get_bit(&tmpitm, idI_BAIT)!=0);
19498 4 temp_zinit.set_item(iHammer, get_bit(&tmpitm, idI_HAMMER)!=0);
19499 4 }
19500
19501
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&tempbyte,f))
19502 return qe_invalid;
19503 271 temp_zinit.mcounter[crLIFE] = tempbyte;
19504
19505
19506
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version < 14)
19507 {
19508 byte temphp;
19509
19510
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19511 {
19512 return qe_invalid;
19513 }
19514
19515 64 temp_zinit.counter[crLIFE]=temphp;
19516
19517
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&temphp,f))
19518 {
19519 return qe_invalid;
19520 }
19521
19522 64 temp_zinit.cont_heart=temphp;
19523 64 }
19524 else
19525 {
19526
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.counter[crLIFE],f))
19527 {
19528 return qe_invalid;
19529 }
19530
19531
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.cont_heart,f))
19532 {
19533 return qe_invalid;
19534 }
19535 }
19536
19537
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.hcp,f))
19538 {
19539 return qe_invalid;
19540 }
19541
19542
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version >= 14)
19543 {
19544
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.hcp_per_hc,f))
19545 {
19546 return qe_invalid;
19547 }
19548
19549
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(s_version<16) // July 2007
19550 {
19551 if(get_qr(qr_BRANGPICKUP+1))
19552 temp_zinit.hcp_per_hc = 0xFF;
19553
19554 //Dispose of legacy rule
19555 set_qr(qr_BRANGPICKUP+1, 0);
19556 }
19557 207 }
19558
19559
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 253 times.
271 if(s_version < 29)
19560 {
19561
1/2
✓ Branch 0 taken 253 times.
✗ Branch 1 not taken.
253 if(!p_getc(&padding,f))
19562 return qe_invalid;
19563 253 temp_zinit.mcounter[crBOMBS] = padding;
19564 253 }
19565
19566
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.counter[crKEYS],f))
19567 {
19568 return qe_invalid;
19569 }
19570
19571
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_igetw(&temp_zinit.counter[crMONEY],f))
19572 {
19573 return qe_invalid;
19574 }
19575
19576
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&tempbyte,f))
19577 return qe_invalid;
19578
2/2
✓ Branch 0 taken 2168 times.
✓ Branch 1 taken 271 times.
2439 for(int q = 0; q < 8; ++q)
19579 2168 set_bit(temp_zinit.mcguffin, q+1, get_bitl(tempbyte, q));
19580
19581
3/6
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 64 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
271 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19582 {
19583
2/2
✓ Branch 0 taken 13248 times.
✓ Branch 1 taken 207 times.
13455 for(int32_t i=0; i<64; i++)
19584 {
19585
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13248 times.
13248 if(!p_getc(&temp_zinit.map[i],f))
19586 {
19587 return qe_invalid;
19588 }
19589 13248 }
19590
19591
2/2
✓ Branch 0 taken 13248 times.
✓ Branch 1 taken 207 times.
13455 for(int32_t i=0; i<64; i++)
19592 {
19593
1/2
✓ Branch 0 taken 13248 times.
✗ Branch 1 not taken.
13248 if(!p_getc(&temp_zinit.compass[i],f))
19594 {
19595 return qe_invalid;
19596 }
19597 13248 }
19598 207 }
19599 else
19600 {
19601
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19602 {
19603
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.map[i],f))
19604 {
19605 return qe_invalid;
19606 }
19607 2048 }
19608
19609
2/2
✓ Branch 0 taken 2048 times.
✓ Branch 1 taken 64 times.
2112 for(int32_t i=0; i<32; i++)
19610 {
19611
1/2
✓ Branch 0 taken 2048 times.
✗ Branch 1 not taken.
2048 if(!p_getc(&temp_zinit.compass[i],f))
19612 {
19613 return qe_invalid;
19614 }
19615 2048 }
19616 }
19617
19618
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
276 if((Header->zelda_version > 0x192)||
19619 //new only
19620
1/2
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
5 ((Header->zelda_version == 0x192)&&(Header->build>173)))
19621 {
19622
3/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 207 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 60 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
267 if(s_version>12 || (Header->zelda_version == 0x211 && Header->build == 18))
19623 {
19624
2/2
✓ Branch 0 taken 13248 times.
✓ Branch 1 taken 207 times.
13455 for(int32_t i=0; i<64; i++)
19625 {
19626
1/2
✓ Branch 0 taken 13248 times.
✗ Branch 1 not taken.
13248 if(!p_getc(&temp_zinit.boss_key[i],f))
19627 {
19628 return qe_invalid;
19629 }
19630 13248 }
19631 207 }
19632 else
19633 {
19634
2/2
✓ Branch 0 taken 1920 times.
✓ Branch 1 taken 60 times.
1980 for(int32_t i=0; i<32; i++)
19635 {
19636
1/2
✓ Branch 0 taken 1920 times.
✗ Branch 1 not taken.
1920 if(!p_getc(&temp_zinit.boss_key[i],f))
19637 {
19638 return qe_invalid;
19639 }
19640 1920 }
19641 }
19642 267 }
19643
19644 byte tmpmisc[16];
19645
2/2
✓ Branch 0 taken 4336 times.
✓ Branch 1 taken 271 times.
4607 for(int32_t i=0; i<16; i++)
19646
1/2
✓ Branch 0 taken 4336 times.
✗ Branch 1 not taken.
4336 if(!p_getc(&tmpmisc[i],f))
19647 return qe_invalid;
19648 271 temp_zinit.flags.set(INIT_FL_CONTPERCENT,get_bit(tmpmisc,0));
19649 271 temp_zinit.magicdrainrate = get_bit(tmpmisc,1) ? 1 : 2; //Double Magic flag
19650 271 temp_zinit.flags.set(INIT_FL_CANSLASH,get_bit(tmpmisc,2));
19651
19652
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 256 times.
✓ Branch 3 taken 64 times.
527 if(s_version < 15) for(int32_t i=0; i<4; i++)
19653
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&sword_hearts[i],f))
19654 64 return qe_invalid;
19655
19656
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.last_map,f))
19657 {
19658 return qe_invalid;
19659 }
19660
19661
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.last_screen,f))
19662 {
19663 return qe_invalid;
19664 }
19665
19666
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version < 14)
19667 {
19668 byte tempmp;
19669
19670
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19671 {
19672 return qe_invalid;
19673 }
19674
19675 64 temp_zinit.mcounter[crMAGIC]=tempmp;
19676
19677
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&tempmp,f))
19678 {
19679 return qe_invalid;
19680 }
19681
19682 64 temp_zinit.counter[crMAGIC]=tempmp;
19683 64 }
19684 else
19685 {
19686
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.mcounter[crMAGIC],f))
19687 {
19688 return qe_invalid;
19689 }
19690
19691
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.counter[crMAGIC],f))
19692 {
19693 return qe_invalid;
19694 }
19695 }
19696
19697
19698
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version < 15)
19699 {
19700
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 64 times.
64 if(s_version < 12)
19701 {
19702 64 temp_zinit.mcounter[crMAGIC]*=32;
19703 64 temp_zinit.counter[crMAGIC]*=32;
19704 64 }
19705
19706
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19707 {
19708
1/2
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
256 if(!p_getc(&beam_hearts[i],f))
19709 {
19710 return qe_invalid;
19711 }
19712 256 }
19713
19714
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&beam_percent,f))
19715 {
19716 return qe_invalid;
19717 }
19718 64 }
19719 else
19720 {
19721
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.bomb_ratio,f))
19722 return qe_invalid;
19723
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(temp_zinit.bomb_ratio < 1)
19724 temp_zinit.bomb_ratio = 1;
19725 207 else bomb_ratio = temp_zinit.bomb_ratio; //jank
19726 }
19727
19728
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
271 if(s_version < 15)
19729 {
19730 byte tempbp;
19731
19732
2/2
✓ Branch 0 taken 256 times.
✓ Branch 1 taken 64 times.
320 for(int32_t i=0; i<4; i++)
19733 {
19734
2/4
✓ Branch 0 taken 256 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 256 times.
✗ Branch 3 not taken.
256 if(!(s_version < 14 ? p_getc(&tempbp,f) : p_igetw(&tempbp,f)))
19735 {
19736 return qe_invalid;
19737 }
19738
19739 256 beam_power[i]=tempbp;
19740 256 }
19741
19742
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(!p_getc(&hookshot_links,f))
19743 {
19744 return qe_invalid;
19745 }
19746
19747
1/2
✓ Branch 0 taken 64 times.
✗ Branch 1 not taken.
64 if(s_version>6)
19748 {
19749 if(!p_getc(&hookshot_length,f))
19750 {
19751 return qe_invalid;
19752 }
19753
19754 if(!p_getc(&longshot_links,f))
19755 {
19756 return qe_invalid;
19757 }
19758
19759 if(!p_getc(&longshot_length,f))
19760 {
19761 return qe_invalid;
19762 }
19763 }
19764 64 }
19765
19766
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.msg_more_x,f))
19767 {
19768 return qe_invalid;
19769 }
19770
19771
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&temp_zinit.msg_more_y,f))
19772 {
19773 return qe_invalid;
19774 }
19775
19776
1/2
✓ Branch 0 taken 271 times.
✗ Branch 1 not taken.
271 if(!p_getc(&subscr_mode,f))
19777 return qe_invalid;
19778
19779 //old only
19780
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
271 if((Header->zelda_version == 0x192)&&(Header->build<174))
19781 {
19782
2/2
✓ Branch 0 taken 128 times.
✓ Branch 1 taken 4 times.
132 for(int32_t i=0; i<32; i++)
19783 {
19784
1/2
✓ Branch 0 taken 128 times.
✗ Branch 1 not taken.
128 if(!p_getc(&temp_zinit.boss_key[i],f))
19785 {
19786 return qe_invalid;
19787 }
19788 128 }
19789 4 }
19790
19791
5/6
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 5 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 1 times.
✓ Branch 5 taken 4 times.
271 if((Header->zelda_version > 0x192)||((Header->zelda_version == 0x192)&&(Header->build>173))) //new only
19792 {
19793
2/2
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 207 times.
267 if(s_version <= 10)
19794 {
19795
1/2
✓ Branch 0 taken 60 times.
✗ Branch 1 not taken.
60 if(!p_getc(&tempbyte,f))
19796 {
19797 return qe_invalid;
19798 }
19799
19800 60 temp_zinit.start_dmap = (word)tempbyte;
19801 60 }
19802 else
19803 {
19804
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.start_dmap,f))
19805 {
19806 return qe_invalid;
19807 }
19808 }
19809
19810
1/2
✓ Branch 0 taken 267 times.
✗ Branch 1 not taken.
267 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
19811 {
19812 return qe_invalid;
19813 }
19814 267 }
19815
19816
4/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 18 times.
✓ Branch 3 taken 189 times.
271 if(s_version>1 && s_version < 29)
19817 {
19818
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&padding,f))
19819 return qe_invalid;
19820 189 temp_zinit.counter[crARROWS] = padding;
19821
19822
1/2
✓ Branch 0 taken 189 times.
✗ Branch 1 not taken.
189 if(!p_getc(&padding,f))
19823 return qe_invalid;
19824 189 temp_zinit.mcounter[crARROWS] = padding;
19825 189 }
19826
19827
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>2)
19828 {
19829
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 if(s_version <= 10)
19830 {
19831 for(int32_t i=0; i<OLDMAXLEVELS; i++)
19832 {
19833 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19834 {
19835 return qe_invalid;
19836 }
19837 }
19838 }
19839 else
19840 {
19841
2/2
✓ Branch 0 taken 105984 times.
✓ Branch 1 taken 207 times.
106191 for(int32_t i=0; i<MAXLEVELS; i++)
19842 {
19843
1/2
✓ Branch 0 taken 105984 times.
✗ Branch 1 not taken.
105984 if(!p_getc(&(temp_zinit.level_keys[i]),f))
19844 {
19845 return qe_invalid;
19846 }
19847 105984 }
19848 }
19849 207 }
19850
19851
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>3)
19852 {
19853
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_x,f))
19854 {
19855 return qe_invalid;
19856 }
19857
19858
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_y,f))
19859 {
19860 return qe_invalid;
19861 }
19862
19863
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_xofs,f))
19864 {
19865 return qe_invalid;
19866 }
19867
19868
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_yofs,f))
19869 {
19870 return qe_invalid;
19871 }
19872
19873
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_grid_color,f))
19874 {
19875 return qe_invalid;
19876 }
19877
19878
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_bbox_1_color,f))
19879 {
19880 return qe_invalid;
19881 }
19882
19883
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_bbox_2_color,f))
19884 {
19885 return qe_invalid;
19886 }
19887
19888
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.ss_flags,f))
19889 {
19890 return qe_invalid;
19891 }
19892
19893
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 temp_zinit.ss_grid_x=zc_max(temp_zinit.ss_grid_x,1);
19894
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 207 times.
207 temp_zinit.ss_grid_y=zc_max(temp_zinit.ss_grid_y,1);
19895 207 }
19896
19897
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
271 if(s_version>4 && s_version<15)
19898 {
19899 if(!p_getc(&moving_fairy_hearts,f))
19900 {
19901 return qe_invalid;
19902 }
19903
19904 if(!p_getc(&moving_fairy_heart_percent,f))
19905 {
19906 return qe_invalid;
19907 }
19908 }
19909
19910
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
271 if(s_version>5 && s_version < 10)
19911 {
19912 if(!p_getc(&temp,f))
19913 {
19914 return qe_invalid;
19915 }
19916
19917 addOldStyleFamily(&temp_zinit, itemsbuf, itype_quiver, temp);
19918 }
19919
19920
3/4
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
✓ Branch 2 taken 207 times.
✗ Branch 3 not taken.
271 if(s_version>6 && s_version<15)
19921 {
19922 if(!p_getc(&stationary_fairy_hearts,f))
19923 {
19924 return qe_invalid;
19925 }
19926
19927 if(!p_getc(&stationary_fairy_heart_percent,f))
19928 {
19929 return qe_invalid;
19930 }
19931
19932 if(!p_getc(&moving_fairy_magic,f))
19933 {
19934 return qe_invalid;
19935 }
19936
19937 if(!p_getc(&moving_fairy_magic_percent,f))
19938 {
19939 return qe_invalid;
19940 }
19941
19942 if(!p_getc(&stationary_fairy_magic,f))
19943 {
19944 return qe_invalid;
19945 }
19946
19947 if(!p_getc(&stationary_fairy_magic_percent,f))
19948 {
19949 return qe_invalid;
19950 }
19951
19952 if(!p_getc(&blue_potion_hearts,f))
19953 {
19954 return qe_invalid;
19955 }
19956
19957 if(!p_getc(&blue_potion_heart_percent,f))
19958 {
19959 return qe_invalid;
19960 }
19961
19962 if(!p_getc(&red_potion_hearts,f))
19963 {
19964 return qe_invalid;
19965 }
19966
19967 if(!p_getc(&red_potion_heart_percent,f))
19968 {
19969 return qe_invalid;
19970 }
19971
19972 if(!p_getc(&blue_potion_magic,f))
19973 {
19974 return qe_invalid;
19975 }
19976
19977 if(!p_getc(&blue_potion_magic_percent,f))
19978 {
19979 return qe_invalid;
19980 }
19981
19982 if(!p_getc(&red_potion_magic,f))
19983 {
19984 return qe_invalid;
19985 }
19986
19987 if(!p_getc(&red_potion_magic_percent,f))
19988 {
19989 return qe_invalid;
19990 }
19991 }
19992
19993
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>6)
19994
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&padding,f))
19995 return qe_invalid;
19996
19997
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>7)
19998 {
19999
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&padding,f))
20000 {
20001 return qe_invalid;
20002 }
20003 207 }
20004
20005
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>8)
20006 {
20007
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.mcounter[crMONEY],f))
20008 {
20009 return qe_invalid;
20010 }
20011
20012
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.mcounter[crKEYS],f))
20013 {
20014 return qe_invalid;
20015 }
20016 207 }
20017
20018
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 64 times.
271 if(s_version>16)
20019 {
20020
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&tempbyte,f))
20021 {
20022 return qe_invalid;
20023 }
20024 207 temp_zinit.gravity = tempbyte*100;
20025
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_igetw(&temp_zinit.terminalv,f))
20026 {
20027 return qe_invalid;
20028 }
20029
20030
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.msg_speed,f))
20031 {
20032 return qe_invalid;
20033 }
20034
20035
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&padding,f))
20036 {
20037 return qe_invalid;
20038 }
20039
20040
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20041 {
20042 return qe_invalid;
20043 }
20044 207 }
20045
2/2
✓ Branch 0 taken 52 times.
✓ Branch 1 taken 12 times.
64 else if (replay_version_check(0, 13))
20046 12 temp_zinit.msg_speed = 0;
20047
20048
2/2
✓ Branch 0 taken 64 times.
✓ Branch 1 taken 207 times.
271 if(s_version>17)
20049 {
20050
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20051 {
20052 return qe_invalid;
20053 }
20054 207 }
20055
20056 //expaned init data for larger values in 2.55
20057
2/2
✓ Branch 0 taken 253 times.
✓ Branch 1 taken 18 times.
271 if ( s_version >= 19 ) //expand init data bombs, sbombs, and arrows to 0xFFFF
20058 {
20059
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crBOMBS],f))
20060 {
20061 return qe_invalid;
20062 }
20063
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crSBOMBS],f))
20064 {
20065 return qe_invalid;
20066 }
20067
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crBOMBS],f))
20068 {
20069 return qe_invalid;
20070 }
20071
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crSBOMBS],f))
20072 {
20073 return qe_invalid;
20074 }
20075
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.counter[crARROWS],f))
20076 {
20077 return qe_invalid;
20078 }
20079
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.mcounter[crARROWS],f))
20080 {
20081 return qe_invalid;
20082 }
20083
20084 18 }
20085
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 253 times.
271 if ( s_version >= 20 )
20086 {
20087
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroStep,f))
20088 {
20089 return qe_invalid;
20090 }
20091 18 }
20092 else
20093 {
20094 253 temp_zinit.heroStep = 150; //1.5 pixels per frame
20095 }
20096
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 253 times.
271 if ( s_version >= 21 )
20097 {
20098
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20099 {
20100 return qe_invalid;
20101 }
20102 18 }
20103 else
20104 {
20105 253 temp_zinit.subscrSpeed = 1; //3 pixels per frame
20106 }
20107 //old only
20108
4/4
✓ Branch 0 taken 5 times.
✓ Branch 1 taken 266 times.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 4 times.
271 if((Header->zelda_version == 0x192)&&(Header->build<174))
20109 {
20110 byte items2;
20111
20112
1/2
✓ Branch 0 taken 4 times.
✗ Branch 1 not taken.
4 if(!p_getc(&items2,f))
20113 {
20114 return qe_invalid;
20115 }
20116
20117 4 temp_zinit.set_item(iDivineFire, get_bit(&items2, idI_DFIRE)!=0);
20118 4 temp_zinit.set_item(iDivineEscape, get_bit(&items2, idI_FWIND)!=0);
20119 4 temp_zinit.set_item(iDivineProtection, get_bit(&items2, idI_NLOVE)!=0);
20120 4 }
20121
20122
2/2
✓ Branch 0 taken 266 times.
✓ Branch 1 taken 5 times.
271 if(Header->zelda_version < 0x193)
20123 {
20124
2/2
✓ Branch 0 taken 480 times.
✓ Branch 1 taken 5 times.
485 for(int32_t q=0; q<96; q++)
20125 {
20126
1/2
✓ Branch 0 taken 480 times.
✗ Branch 1 not taken.
480 if(!p_getc(&padding,f))
20127 {
20128 return qe_invalid;
20129 }
20130 480 }
20131
20132 //new only
20133
3/4
✓ Branch 0 taken 5 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 4 times.
✓ Branch 3 taken 1 times.
5 if((Header->zelda_version == 0x192)&&(Header->build>173))
20134 {
20135
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20136 {
20137 return qe_invalid;
20138 }
20139
20140
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(!p_getc(&padding,f))
20141 {
20142 return qe_invalid;
20143 }
20144 1 }
20145 5 }
20146 271 }
20147
20148
3/6
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 207 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
289 if((Header->zelda_version < 0x211)||((Header->zelda_version == 0x211)&&(Header->build<15)))
20149 {
20150 //temp_zinit.shield=i_smallshield;
20151 82 int32_t sshieldid = getItemID(itemsbuf, itype_shield, i_smallshield);
20152
20153
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if(sshieldid != -1)
20154 82 temp_zinit.set_item(sshieldid, true);
20155 82 }
20156
20157
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<27)))
20158 {
20159 18 temp_zinit.mcounter[crLIFE]=3;
20160 18 temp_zinit.counter[crLIFE]=3;
20161 18 temp_zinit.cont_heart=3;
20162 18 temp_zinit.mcounter[crBOMBS]=8;
20163 18 }
20164
20165
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<50)))
20166 {
20167 18 sword_hearts[0]=0;
20168 18 sword_hearts[1]=5;
20169 18 sword_hearts[2]=12;
20170 18 sword_hearts[3]=21;
20171 18 }
20172
20173
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<51)))
20174 {
20175 18 temp_zinit.last_map=0;
20176 18 temp_zinit.last_screen=0;
20177 18 }
20178
20179
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<68)))
20180 {
20181 18 temp_zinit.mcounter[crMAGIC]=0;
20182 18 temp_zinit.counter[crMAGIC]=0;
20183 18 temp_zinit.magicdrainrate = 2;
20184 18 }
20185
20186
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✗ Branch 4 not taken.
✓ Branch 5 taken 5 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<129)))
20187 {
20188
20189
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20190 {
20191 72 beam_hearts[x]=100;
20192 72 }
20193
20194
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t i=0; i<idBP_MAX; i++)
20195 {
20196 72 set_bit(&beam_percent,i,!get_qr(qr_LENSHINTS+i));
20197 72 set_qr(qr_LENSHINTS+i,0);
20198 72 }
20199
20200
2/2
✓ Branch 0 taken 72 times.
✓ Branch 1 taken 18 times.
90 for(int32_t x=0; x<4; x++)
20201 {
20202 72 beam_power[x]=get_qr(qr_HIDECARRIEDITEMS)?50:100;
20203 72 }
20204
20205 18 set_qr(qr_HIDECARRIEDITEMS,0);
20206 18 hookshot_links=100;
20207 18 temp_zinit.msg_more_x=224;
20208 18 temp_zinit.msg_more_y=64;
20209 18 }
20210
20211 // Okay, let's put these legacy values into itemsbuf.
20212
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
289 if(s_version < 15)
20213
2/2
✓ Branch 0 taken 20992 times.
✓ Branch 1 taken 82 times.
21074 for(int32_t i=0; i<MAXITEMS; i++)
20214 {
20215
11/11
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 82 times.
✓ Branch 2 taken 82 times.
✓ Branch 3 taken 82 times.
✓ Branch 4 taken 82 times.
✓ Branch 5 taken 82 times.
✓ Branch 6 taken 82 times.
✓ Branch 7 taken 82 times.
✓ Branch 8 taken 20172 times.
✓ Branch 9 taken 82 times.
✓ Branch 10 taken 82 times.
20992 switch(i)
20216 {
20217 case iFairyStill:
20218 82 itemsbuf[i].misc1 = stationary_fairy_hearts;
20219 82 itemsbuf[i].misc2 = stationary_fairy_magic;
20220 82 itemsbuf[i].misc3 = 0;
20221
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20222
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (stationary_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20223 82 break;
20224
20225 case iFairyMoving:
20226 82 itemsbuf[i].misc1 = moving_fairy_hearts;
20227 82 itemsbuf[i].misc2 = moving_fairy_magic;
20228 82 itemsbuf[i].misc3 = 50;
20229
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_heart_percent) itemsbuf[i].flags |= item_flag1;
20230
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 if (moving_fairy_magic_percent) itemsbuf[i].flags |= item_flag2;
20231 82 break;
20232
20233 case iRPotion:
20234 82 itemsbuf[i].misc1 = red_potion_hearts;
20235 82 itemsbuf[i].misc2 = red_potion_magic;
20236
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20237
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (red_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20238 82 break;
20239
20240 case iBPotion:
20241 82 itemsbuf[i].misc1 = blue_potion_hearts;
20242 82 itemsbuf[i].misc2 = blue_potion_magic;
20243
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_heart_percent) itemsbuf[i].flags |= item_flag1;
20244
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 82 times.
82 if (blue_potion_magic_percent) itemsbuf[i].flags |= item_flag2;
20245 82 break;
20246
20247 case iSword:
20248 82 itemsbuf[i].pickup_hearts = sword_hearts[0];
20249 82 itemsbuf[i].misc1 = beam_hearts[0];
20250 82 itemsbuf[i].misc2 = beam_power[0];
20251 // It seems that item_flag1 was already added by reset_itembuf()...
20252 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,0)) ? ~item_flag1 : ~item_none;
20253 82 break;
20254
20255 case iWSword:
20256 82 itemsbuf[i].pickup_hearts = sword_hearts[1];
20257 82 itemsbuf[i].misc1 = beam_hearts[1];
20258 82 itemsbuf[i].misc2 = beam_power[1];
20259 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,1)) ? ~item_flag1 : ~item_none;
20260 82 break;
20261
20262 case iMSword:
20263 82 itemsbuf[i].pickup_hearts = sword_hearts[2];
20264 82 itemsbuf[i].misc1 = beam_hearts[2];
20265 82 itemsbuf[i].misc2 = beam_power[2];
20266 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,2)) ? ~item_flag1 : ~item_none;
20267 82 break;
20268
20269 case iXSword:
20270 82 itemsbuf[i].pickup_hearts = sword_hearts[3];
20271 82 itemsbuf[i].misc1 = beam_hearts[3];
20272 82 itemsbuf[i].misc2 = beam_power[3];
20273 82 itemsbuf[i].flags &= (!get_bit(&beam_percent,3)) ? ~item_flag1 : ~item_none;
20274 82 break;
20275
20276 case iHookshot:
20277 82 itemsbuf[i].misc1 = hookshot_length;
20278 82 itemsbuf[i].misc2 = hookshot_links;
20279 82 break;
20280
20281 case iLongshot:
20282 82 itemsbuf[i].misc1 = longshot_length;
20283 82 itemsbuf[i].misc2 = longshot_links;
20284 82 break;
20285 }
20286 21074 }
20287
20288
6/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✓ Branch 4 taken 4 times.
✓ Branch 5 taken 1 times.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<168)))
20289 {
20290 //was new subscreen rule
20291 22 subscr_mode=get_qr(qr_FREEFORM)?1:0;
20292 22 set_qr(qr_FREEFORM,0);
20293 22 }
20294
20295
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<185)))
20296 {
20297 23 temp_zinit.start_dmap=0;
20298 23 }
20299
20300
5/6
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
✓ Branch 2 taken 5 times.
✓ Branch 3 taken 266 times.
✓ Branch 4 taken 5 times.
✗ Branch 5 not taken.
289 if((Header->zelda_version < 0x192)||((Header->zelda_version == 0x192)&&(Header->build<186)))
20301 {
20302 23 temp_zinit.heroAnimationStyle=get_qr(qr_BSZELDA)?1:0;
20303 23 }
20304
20305
3/4
✓ Branch 0 taken 82 times.
✓ Branch 1 taken 207 times.
✓ Branch 2 taken 82 times.
✗ Branch 3 not taken.
289 if(s_version < 16 && get_bit(deprecated_rules, qr_COOLSCROLL+1))
20306 {
20307 //addOldStyleFamily(&temp_zinit, itemsbuf, itype_wallet, 4); //is this needed?
20308 temp_zinit.mcounter[crMONEY]=999;
20309 //temp_zinit.counter[crMONEY]=999; //This rule only gave you an invisible max wallet; it did not give you max rupies.
20310 }
20311
2/2
✓ Branch 0 taken 283 times.
✓ Branch 1 taken 6 times.
289 if(Header->zelda_version < 0x190) //1.84 bugfix. -Z
20312 {
20313 //temp_zinit.items[iBombBag] = true; //No, this is 30 max bombs!
20314 6 temp_zinit.mcounter[crBOMBS] = 8;
20315 6 }
20316 // al_trace("About to copy over new init data values for quest made in: %x\n", Header->zelda_version);
20317 //time to ensure that we port all new values properly:
20318
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 82 times.
289 if(Header->zelda_version < 0x250)
20319 {
20320
1/2
✓ Branch 0 taken 82 times.
✗ Branch 1 not taken.
82 temp_zinit.mcounter[crSBOMBS] = bomb_ratio > 0 ? ( temp_zinit.mcounter[crBOMBS]/temp_zinit.bomb_ratio ) : (temp_zinit.mcounter[crBOMBS]/4);
20321 82 }
20322
20323
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 21)
20324 {
20325
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.hp_per_heart,f))
20326 {
20327 return qe_invalid;
20328 }
20329
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.magic_per_block,f))
20330 {
20331 return qe_invalid;
20332 }
20333
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20334 {
20335 return qe_invalid;
20336 }
20337
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20338 {
20339 return qe_invalid;
20340 }
20341 18 }
20342 else
20343 {
20344 271 temp_zinit.hp_per_heart = 16; //HP_PER_HEART, previously hardcoded
20345 271 temp_zinit.magic_per_block = 32; //MAGICPERBLOCK, previously hardcoded
20346 271 temp_zinit.hero_damage_multiplier = 2; //DAMAGE_MULTIPLIER, previously hardcoded
20347 271 temp_zinit.ene_damage_multiplier = 4; //(HP_PER_HEART/4), previously hardcoded
20348 }
20349
20350
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
289 if(s_version > 22)
20351 {
20352
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 18 times.
468 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20353
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if(!p_igetw(&temp_zinit.counter[q],f))
20354 return qe_invalid;
20355
2/2
✓ Branch 0 taken 450 times.
✓ Branch 1 taken 18 times.
468 for(int32_t q = crCUSTOM1; q <= crCUSTOM25; ++q)
20356
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 450 times.
450 if(!p_igetw(&temp_zinit.mcounter[q],f))
20357 return qe_invalid;
20358 18 }
20359
20360
20361
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 23)
20362 {
20363
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_type,f))
20364 {
20365 return qe_invalid;
20366 }
20367
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_arg,f))
20368 {
20369 return qe_invalid;
20370 }
20371
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.dither_percent,f))
20372 {
20373 return qe_invalid;
20374 }
20375
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.def_lightrad,f))
20376 {
20377 return qe_invalid;
20378 }
20379
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.transdark_percent,f))
20380 {
20381 return qe_invalid;
20382 }
20383 18 }
20384 else
20385 {
20386 271 temp_zinit.dither_type = 0;
20387 271 temp_zinit.dither_arg = 0;
20388 271 temp_zinit.dither_percent = 20;
20389 271 temp_zinit.def_lightrad = 24;
20390 271 temp_zinit.transdark_percent = 0;
20391 }
20392
20393
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 24)
20394 {
20395
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.darkcol,f))
20396 {
20397 return qe_invalid;
20398 }
20399 18 }
20400 else
20401 {
20402 271 temp_zinit.darkcol = BLACK;
20403 }
20404
20405
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
289 if(s_version > 25)
20406 {
20407
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.gravity,f))
20408 {
20409 return qe_invalid;
20410 }
20411
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.swimgravity,f))
20412 {
20413 return qe_invalid;
20414 }
20415 18 }
20416
20417
20418
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 26)
20419 {
20420
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20421 {
20422 return qe_invalid;
20423 }
20424
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20425 {
20426 return qe_invalid;
20427 }
20428
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20429 {
20430 return qe_invalid;
20431 }
20432 18 }
20433 else
20434 {
20435 271 temp_zinit.heroSideswimUpStep = 150;
20436 271 temp_zinit.heroSideswimSideStep = 100;
20437 271 temp_zinit.heroSideswimDownStep = 75;
20438 }
20439
20440
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 27)
20441 {
20442
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20443 {
20444 return qe_invalid;
20445 }
20446 18 }
20447 else
20448 {
20449 271 temp_zinit.exitWaterJump = 0;
20450 }
20451
20452
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 29)
20453 {
20454
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20455 {
20456 return qe_invalid;
20457 }
20458 18 }
20459 else
20460 {
20461 271 temp_zinit.bunny_ltm = 0;
20462 }
20463
20464
2/2
✓ Branch 0 taken 18 times.
✓ Branch 1 taken 271 times.
289 if(s_version > 30)
20465 {
20466
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.switchhookstyle,f))
20467 {
20468 return qe_invalid;
20469 }
20470 18 }
20471 else
20472 {
20473 271 temp_zinit.switchhookstyle = 1;
20474 }
20475
20476
2/2
✓ Branch 0 taken 271 times.
✓ Branch 1 taken 18 times.
289 if(s_version > 31)
20477 {
20478
1/2
✓ Branch 0 taken 18 times.
✗ Branch 1 not taken.
18 if(!p_getc(&temp_zinit.magicdrainrate,f))
20479 {
20480 return qe_invalid;
20481 }
20482 18 }
20483
20484 289 temp_zinit.clear_genscript();
20485
2/2
✓ Branch 0 taken 276 times.
✓ Branch 1 taken 13 times.
289 if(s_version > 32)
20486 {
20487 13 word numgenscript = 0;
20488
1/2
✓ Branch 0 taken 13 times.
✗ Branch 1 not taken.
13 if(!p_igetw(&numgenscript,f))
20489 return qe_invalid;
20490
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 if (numgenscript > NUMSCRIPTSGENERIC)
20491 return qe_invalid;
20492
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 13 times.
13 for(auto q = 1; q < numgenscript; ++q)
20493 {
20494 if(!p_getc(&tempbyte,f))
20495 return qe_invalid;
20496 if(!(tempbyte&2))
20497 continue;
20498 temp_zinit.gen_doscript.set(q, tempbyte&1);
20499 if(!p_igetw(&temp_zinit.gen_exitState[q],f))
20500 return qe_invalid;
20501 if(!p_igetw(&temp_zinit.gen_reloadState[q],f))
20502 return qe_invalid;
20503 for(auto p = 0; p < 8; ++p)
20504 if(!p_igetl(&temp_zinit.gen_initd[q][p],f))
20505 return qe_invalid;
20506 dword sz;
20507 if(!p_igetl(&sz,f))
20508 return qe_invalid;
20509 temp_zinit.gen_data[q].resize(sz);
20510 std::vector<int32_t> dummy;
20511 if(!p_getlvec(&dummy,f))
20512 return qe_invalid;
20513 temp_zinit.gen_data[q] = dummy;
20514 if(!p_igetl(&temp_zinit.gen_eventstate[q],f))
20515 return qe_invalid;
20516 }
20517 13 }
20518
2/2
✓ Branch 0 taken 282 times.
✓ Branch 1 taken 7 times.
289 if(s_version > 33)
20519 {
20520
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20521 return qe_invalid;
20522
1/2
✓ Branch 0 taken 7 times.
✗ Branch 1 not taken.
7 if(!p_getc(&temp_zinit.hero_swim_div,f))
20523 return qe_invalid;
20524 7 }
20525
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 if(s_version > 34)
20526 {
20527 uint32_t num_used_mapscr_data;
20528 if(!p_igetl(&num_used_mapscr_data,f))
20529 return qe_invalid;
20530 for(uint32_t q = 0; q < num_used_mapscr_data; ++q)
20531 {
20532 uint32_t sz;
20533 if(!p_igetl(&sz,f))
20534 return qe_invalid;
20535 temp_zinit.screen_data[q].resize(sz);
20536 if(sz)
20537 {
20538 std::vector<int32_t> dummy;
20539 if(!p_getlvec(&dummy,f))
20540 return qe_invalid;
20541 temp_zinit.screen_data[q] = dummy;
20542 }
20543 }
20544 }
20545
1/2
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
289 if (s_version > 35)
20546 if(!p_igetzf(&temp_zinit.shove_offset,f))
20547 return qe_invalid;
20548
20549 289 temp_zinit.counter[crLIFE] *= temp_zinit.hp_per_heart;
20550 289 temp_zinit.mcounter[crLIFE] *= temp_zinit.hp_per_heart;
20551
2/2
✓ Branch 0 taken 188 times.
✓ Branch 1 taken 101 times.
289 if(!temp_zinit.flags.get(INIT_FL_CONTPERCENT))
20552 101 temp_zinit.cont_heart *= temp_zinit.hp_per_heart;
20553
20554 289 return 0;
20555 289 }
20556 694 int32_t readinitdata(PACKFILE *f, zquestheader *Header)
20557 {
20558 694 zinitdata temp_zinit = {};
20559
20560
3/4
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 23 times.
✓ Branch 2 taken 23 times.
✗ Branch 3 not taken.
694 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_initdata);
20561
20562 int32_t dummy;
20563 694 word s_version=0, s_cversion=0;
20564 byte padding;
20565
20566
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 23 times.
694 if(Header->zelda_version > 0x192)
20567 {
20568
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&s_version,f))
20569 return qe_invalid;
20570 671 FFCore.quest_format[vInitData] = s_version;
20571
20572
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetw(&s_cversion,f))
20573 return qe_invalid;
20574
20575 //section size
20576
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!p_igetl(&dummy,f))
20577 return qe_invalid;
20578 671 }
20579
20580
2/2
✓ Branch 0 taken 289 times.
✓ Branch 1 taken 405 times.
694 if(s_version < 37)
20581 {
20582
2/4
✓ Branch 0 taken 289 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 289 times.
289 if(auto ret = readinitdata_old(f,Header,s_version,s_cversion,temp_zinit))
20583 return ret;
20584 289 }
20585 else
20586 {
20587 405 subscr_mode = ssdtMAX;
20588
2/2
✓ Branch 0 taken 12960 times.
✓ Branch 1 taken 405 times.
13365 for(int q = 0; q < MAXITEMS/8; ++q)
20589
2/4
✓ Branch 0 taken 12960 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 12960 times.
12960 if(!p_getc(&temp_zinit.items[q], f))
20590 return qe_invalid;
20591
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 25920 times.
26325 for(int q = 0; q < MAXLEVELS/8; ++q)
20592 {
20593
2/4
✓ Branch 0 taken 25920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25920 times.
✗ Branch 3 not taken.
25920 if(!p_getc(&temp_zinit.map[q], f))
20594 return qe_invalid;
20595
2/4
✓ Branch 0 taken 25920 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25920 times.
25920 if(!p_getc(&temp_zinit.compass[q], f))
20596 return qe_invalid;
20597
2/4
✓ Branch 0 taken 25920 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 25920 times.
25920 if(!p_getc(&temp_zinit.boss_key[q], f))
20598 return qe_invalid;
20599
2/4
✓ Branch 0 taken 25920 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 25920 times.
✗ Branch 3 not taken.
25920 if(!p_getc(&temp_zinit.mcguffin[q], f))
20600 return qe_invalid;
20601 25920 }
20602
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getbvec(&temp_zinit.level_keys, f))
20603 return qe_invalid;
20604 byte num_counters;
20605
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&num_counters,f))
20606 return qe_invalid;
20607
2/2
✓ Branch 0 taken 43335 times.
✓ Branch 1 taken 405 times.
43740 for(int q = 0; q < num_counters; ++q)
20608
2/4
✓ Branch 0 taken 43335 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43335 times.
43335 if(!p_igetw(&temp_zinit.counter[q],f))
20609 return qe_invalid;
20610
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 43335 times.
43740 for(int q = 0; q < num_counters; ++q)
20611
2/4
✓ Branch 0 taken 43335 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 43335 times.
43335 if(!p_igetw(&temp_zinit.mcounter[q],f))
20612 return qe_invalid;
20613
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.bomb_ratio,f))
20614 return qe_invalid;
20615
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.hcp,f))
20616 return qe_invalid;
20617
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.hcp_per_hc,f))
20618 return qe_invalid;
20619
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetw(&temp_zinit.cont_heart,f))
20620 return qe_invalid;
20621
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.hp_per_heart,f))
20622 return qe_invalid;
20623
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.magic_per_block,f))
20624 return qe_invalid;
20625
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.hero_damage_multiplier,f))
20626 return qe_invalid;
20627
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.ene_damage_multiplier,f))
20628 return qe_invalid;
20629
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.dither_type,f))
20630 return qe_invalid;
20631
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.dither_arg,f))
20632 return qe_invalid;
20633
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.dither_percent,f))
20634 return qe_invalid;
20635
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.def_lightrad,f))
20636 return qe_invalid;
20637
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.transdark_percent,f))
20638 return qe_invalid;
20639
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.darkcol,f))
20640 return qe_invalid;
20641
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.ss_grid_x,f))
20642 return qe_invalid;
20643
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.ss_grid_y,f))
20644 return qe_invalid;
20645
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.ss_grid_xofs,f))
20646 return qe_invalid;
20647
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.ss_grid_yofs,f))
20648 return qe_invalid;
20649
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.ss_grid_color,f))
20650 return qe_invalid;
20651
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.ss_bbox_1_color,f))
20652 return qe_invalid;
20653
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.ss_bbox_2_color,f))
20654 return qe_invalid;
20655
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.ss_flags,f))
20656 return qe_invalid;
20657
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getbitstr(&temp_zinit.flags,f))
20658 return qe_invalid;
20659
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.last_map,f))
20660 return qe_invalid;
20661
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.last_screen,f))
20662 return qe_invalid;
20663
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.msg_more_x,f))
20664 return qe_invalid;
20665
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.msg_more_y,f))
20666 return qe_invalid;
20667
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.msg_more_is_offset,f))
20668 return qe_invalid;
20669
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.msg_speed,f))
20670 return qe_invalid;
20671
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.gravity,f))
20672 return qe_invalid;
20673
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.swimgravity,f))
20674 return qe_invalid;
20675
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetw(&temp_zinit.terminalv,f))
20676 return qe_invalid;
20677
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.hero_swim_speed,f))
20678 return qe_invalid;
20679
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.hero_swim_mult,f))
20680 return qe_invalid;
20681
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.hero_swim_div,f))
20682 return qe_invalid;
20683
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetw(&temp_zinit.heroSideswimUpStep,f))
20684 return qe_invalid;
20685
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetw(&temp_zinit.heroSideswimSideStep,f))
20686 return qe_invalid;
20687
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetw(&temp_zinit.heroSideswimDownStep,f))
20688 return qe_invalid;
20689
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.exitWaterJump,f))
20690 return qe_invalid;
20691
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetw(&temp_zinit.heroStep,f))
20692 return qe_invalid;
20693
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.heroAnimationStyle,f))
20694 return qe_invalid;
20695
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.jump_hero_layer_threshold,f))
20696 return qe_invalid;
20697
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetl(&temp_zinit.bunny_ltm,f))
20698 return qe_invalid;
20699
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetw(&temp_zinit.start_dmap,f))
20700 return qe_invalid;
20701
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetw(&temp_zinit.subscrSpeed,f))
20702 return qe_invalid;
20703
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.switchhookstyle,f))
20704 return qe_invalid;
20705
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getc(&temp_zinit.magicdrainrate,f))
20706 return qe_invalid;
20707
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_igetzf(&temp_zinit.shove_offset,f))
20708 return qe_invalid;
20709
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getbitstr(&temp_zinit.gen_doscript, f))
20710 return qe_invalid;
20711
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getbmap(&temp_zinit.gen_exitState, f))
20712 return qe_invalid;
20713
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getbmap(&temp_zinit.gen_reloadState, f))
20714 return qe_invalid;
20715
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getbmap(&temp_zinit.gen_initd, f))
20716 return qe_invalid;
20717
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getbmap(&temp_zinit.gen_eventstate, f))
20718 return qe_invalid;
20719
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getbmap(&temp_zinit.gen_data, f))
20720 return qe_invalid;
20721
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if(!p_getbmap(&temp_zinit.screen_data, f))
20722 return qe_invalid;
20723
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if (s_version >= 38)
20724 {
20725
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if (!p_getc(&temp_zinit.spriteflickerspeed, f))
20726 return qe_invalid;
20727
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if (!p_getc(&temp_zinit.spriteflickercolor, f))
20728 return qe_invalid;
20729
2/4
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 405 times.
✗ Branch 3 not taken.
405 if (!p_getc(&temp_zinit.spriteflickertransp, f))
20730 return qe_invalid;
20731 405 }
20732
2/2
✓ Branch 0 taken 105 times.
✓ Branch 1 taken 300 times.
405 if(s_version >= 39)
20733
2/4
✓ Branch 0 taken 105 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 105 times.
✗ Branch 3 not taken.
105 if(!p_igetzf(&temp_zinit.air_drag, f))
20734 return qe_invalid;
20735 }
20736
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 if (should_skip)
20737 return 0;
20738
20739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
694 if(loading_tileset_flags & TILESET_CLEARMAPS)
20740 {
20741 temp_zinit.last_map = 0;
20742 temp_zinit.last_screen = 0;
20743 temp_zinit.screen_data.clear();
20744 }
20745
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 temp_zinit.normalize();
20746
1/2
✓ Branch 0 taken 694 times.
✗ Branch 1 not taken.
694 zinit = temp_zinit;
20747
20748
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 694 times.
694 if(zinit.heroAnimationStyle==las_zelda3slow)
20749 {
20750 hero_animation_speed=2;
20751 }
20752 else
20753 {
20754 694 hero_animation_speed=1;
20755 }
20756
20757 694 return 0;
20758 694 }
20759
20760 /*
20761 void setupitemdropsets()
20762 {
20763 for(int32_t i=0; i<isMAX; i++)
20764 {
20765 memcpy(&item_drop_sets[i], &default_item_drop_sets[i], sizeof(item_drop_object));
20766 }
20767 }
20768 */
20769
20770 635 int32_t readitemdropsets(PACKFILE *f, int32_t version, word build)
20771 {
20772
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 23 times.
635 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_itemdropsets);
20773
20774 635 build=build; // here to prevent compiler warnings
20775 dword dummy_dword;
20776 635 word item_drop_sets_to_read=0;
20777 item_drop_object tempitemdrop;
20778 635 word s_version=0, s_cversion=0;
20779
20780
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 635 times.
635 if (!should_skip)
20781
2/2
✓ Branch 0 taken 162560 times.
✓ Branch 1 taken 635 times.
163195 for(int32_t i=0; i<MAXITEMDROPSETS; i++)
20782 {
20783 162560 memset(&item_drop_sets[i], 0, sizeof(item_drop_object));
20784 163195 }
20785
20786
2/2
✓ Branch 0 taken 612 times.
✓ Branch 1 taken 23 times.
635 if(version > 0x192)
20787 {
20788 612 item_drop_sets_to_read=0;
20789
20790 //section version info
20791
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&s_version,f))
20792 {
20793 return qe_invalid;
20794 }
20795
20796 612 FFCore.quest_format[vItemDropsets] = s_version;
20797
20798
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&s_cversion,f))
20799 {
20800 return qe_invalid;
20801 }
20802
20803 //section size
20804
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetl(&dummy_dword,f))
20805 {
20806 return qe_invalid;
20807 }
20808
20809 //finally... section data
20810
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&item_drop_sets_to_read,f))
20811 {
20812 return qe_invalid;
20813 }
20814
20815
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if (item_drop_sets_to_read > MAXITEMDROPSETS)
20816 {
20817 return qe_invalid;
20818 }
20819 612 }
20820 else
20821 {
20822 23 init_item_drop_sets();
20823 }
20824
20825
2/2
✓ Branch 0 taken 23 times.
✓ Branch 1 taken 612 times.
635 if(s_version>=1)
20826 {
20827
2/2
✓ Branch 0 taken 8791 times.
✓ Branch 1 taken 612 times.
9403 for(int32_t i=0; i<item_drop_sets_to_read; i++)
20828 {
20829
1/2
✓ Branch 0 taken 8791 times.
✗ Branch 1 not taken.
8791 if(!p_getstr(tempitemdrop.name,sizeof(tempitemdrop.name)-1,f))
20830 {
20831 return qe_invalid;
20832 }
20833
20834
2/2
✓ Branch 0 taken 87910 times.
✓ Branch 1 taken 8791 times.
96701 for(int32_t j=0; j<10; ++j)
20835 {
20836
1/2
✓ Branch 0 taken 87910 times.
✗ Branch 1 not taken.
87910 if(!p_igetw(&tempitemdrop.item[j],f))
20837 {
20838 return qe_invalid;
20839 }
20840 87910 }
20841
20842
2/2
✓ Branch 0 taken 96701 times.
✓ Branch 1 taken 8791 times.
105492 for(int32_t j=0; j<11; ++j)
20843 {
20844
1/2
✓ Branch 0 taken 96701 times.
✗ Branch 1 not taken.
96701 if(!p_igetw(&tempitemdrop.chance[j],f))
20845 {
20846 return qe_invalid;
20847 }
20848 96701 }
20849
20850 // Dec 2008: Addition of the 'Tall Grass' set, #12,
20851 // overrides the quest's set #12.
20852
1/4
✗ Branch 0 not taken.
✓ Branch 1 taken 8791 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8791 if(s_version<2 && i==12)
20853 continue;
20854
20855 // Deprecated: qr_NOCLOCKS and qr_ALLOW10RUPEEDROPS
20856
1/4
✓ Branch 0 taken 8791 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
8791 if(s_version<2) for(int32_t j=0; j<10; ++j)
20857 {
20858 int32_t it = tempitemdrop.item[j];
20859
20860 if((itemsbuf[it].family == itype_rupee
20861 && ((itemsbuf[it].amount)&0xFFF) == 10)
20862 && !get_bit(deprecated_rules, qr_ALLOW10RUPEEDROPS_DEP))
20863 {
20864 tempitemdrop.chance[j+1]=0;
20865 }
20866 else if(itemsbuf[it].family == itype_clock && get_bit(deprecated_rules, qr_NOCLOCKS_DEP))
20867 {
20868 tempitemdrop.chance[j+1]=0;
20869 }
20870
20871 // From Sept 2007 to Dec 2008, non-gameplay items were prohibited.
20872 if(itemsbuf[it].family == itype_misc)
20873 {
20874 // If a non-gameplay item was selected, then item drop was aborted.
20875 // Reflect this by increasing the 'Nothing' chance accordingly.
20876 tempitemdrop.chance[0]+=tempitemdrop.chance[j+1];
20877 tempitemdrop.chance[j+1]=0;
20878 }
20879 }
20880
20881
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 8791 times.
8791 if (!should_skip)
20882 8791 memcpy(&item_drop_sets[i], &tempitemdrop, sizeof(item_drop_object));
20883 8791 }
20884 612 }
20885
20886 635 return 0;
20887 635 }
20888
20889 612 int32_t readfavorites(PACKFILE *f, int32_t, word)
20890 {
20891
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 bool should_skip = legacy_skip_flags && get_bit(legacy_skip_flags, skip_favorites);
20892
20893 int32_t temp_num;
20894 dword dummy_dword;
20895 word num_favorite_combos;
20896 word num_favorite_combo_aliases;
20897 612 word s_version=0, s_cversion=0;
20898
20899 //section version info
20900
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&s_version,f))
20901 {
20902 return qe_invalid;
20903 }
20904
20905
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if (!should_skip)
20906 612 FFCore.quest_format[vFavourites] = s_version;
20907
20908
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&s_cversion,f))
20909 {
20910 return qe_invalid;
20911 }
20912
20913 //section size
20914
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetl(&dummy_dword,f))
20915 {
20916 return qe_invalid;
20917 }
20918
20919 612 word per_row = FAVORITECOMBO_PER_ROW;
20920 612 word per_page = FAVORITECOMBO_PER_PAGE;
20921
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 412 times.
612 if(s_version >= 3)
20922
1/2
✓ Branch 0 taken 412 times.
✗ Branch 1 not taken.
412 if(!p_igetw(&per_row,f))
20923 return qe_invalid;
20924
2/2
✓ Branch 0 taken 207 times.
✓ Branch 1 taken 405 times.
612 if(s_version >= 4)
20925
1/2
✓ Branch 0 taken 405 times.
✗ Branch 1 not taken.
405 if(!p_igetw(&per_page,f))
20926 return qe_invalid;
20927 //finally... section data
20928
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 if(!p_igetw(&num_favorite_combos,f))
20929 {
20930 return qe_invalid;
20931 }
20932
20933 //Hack; port old favorite combos
20934
3/4
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 412 times.
✗ Branch 2 not taken.
✓ Branch 3 taken 200 times.
612 if(s_version < 3 && num_favorite_combos == 100)
20935 200 per_row = 13;
20936
20937
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if (!should_skip)
20938
2/2
✓ Branch 0 taken 771120 times.
✓ Branch 1 taken 612 times.
771732 for(int q = 0; q < MAXFAVORITECOMBOS; ++q)
20939 771732 favorite_combos[q] = -1;
20940 612 byte favtype = 0;
20941
2/2
✓ Branch 0 taken 63616 times.
✓ Branch 1 taken 612 times.
64228 for(int32_t i=0; i<num_favorite_combos; i++)
20942 {
20943
2/2
✓ Branch 0 taken 43609 times.
✓ Branch 1 taken 20007 times.
63616 if (s_version >= 4)
20944 {
20945
1/2
✓ Branch 0 taken 43609 times.
✗ Branch 1 not taken.
43609 if (!p_getc(&favtype, f))
20946 {
20947 return qe_invalid;
20948 }
20949 43609 }
20950 else
20951 20007 favtype = 0;
20952
1/2
✓ Branch 0 taken 63616 times.
✗ Branch 1 not taken.
63616 if(!p_igetl(&temp_num,f))
20953 {
20954 return qe_invalid;
20955 }
20956
20957
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 63616 times.
63616 if (should_skip)
20958 continue;
20959
20960
2/2
✓ Branch 0 taken 43609 times.
✓ Branch 1 taken 20007 times.
63616 if(per_row == FAVORITECOMBO_PER_ROW)
20961 {
20962 43609 favorite_combos[i] = temp_num;
20963 43609 favorite_combo_modes[i] = favtype;
20964 43609 }
20965 else
20966 {
20967 20007 int new_i = (i%per_row) + (i/per_row)*FAVORITECOMBO_PER_ROW;
20968 20007 favorite_combos[new_i]=temp_num;
20969 20007 favorite_combo_modes[new_i] = favtype;
20970 }
20971 63616 }
20972
20973 // Discard the separate favorite aliases list from previous versions
20974
2/2
✓ Branch 0 taken 405 times.
✓ Branch 1 taken 207 times.
612 if(s_version<4)
20975 {
20976
1/2
✓ Branch 0 taken 207 times.
✗ Branch 1 not taken.
207 if (!p_igetw(&num_favorite_combo_aliases, f))
20977 {
20978 return qe_invalid;
20979 }
20980
20981
2/2
✓ Branch 0 taken 20000 times.
✓ Branch 1 taken 207 times.
20207 for (int32_t i = 0; i < num_favorite_combo_aliases; i++)
20982 {
20983
1/2
✓ Branch 0 taken 20000 times.
✗ Branch 1 not taken.
20000 if (!p_igetl(&temp_num, f))
20984 {
20985 return qe_invalid;
20986 }
20987 20000 }
20988 207 }
20989
20990 612 word max_combo_cols = 0;
20991 612 word max_mappages = 0;
20992
2/2
✓ Branch 0 taken 200 times.
✓ Branch 1 taken 412 times.
612 if(s_version >= 2)
20993 {
20994
1/2
✓ Branch 0 taken 412 times.
✗ Branch 1 not taken.
412 if(!p_igetw(&max_combo_cols,f))
20995 return qe_invalid;
20996 412 int32_t tmp = 0, tmp2 = 0, tmp3 = 0;
20997
2/2
✓ Branch 0 taken 1648 times.
✓ Branch 1 taken 412 times.
2060 for(int q = 0; q < max_combo_cols; ++q)
20998 {
20999
1/2
✓ Branch 0 taken 1648 times.
✗ Branch 1 not taken.
1648 if(!p_igetl(&tmp,f))
21000 return qe_invalid;
21001
1/2
✓ Branch 0 taken 1648 times.
✗ Branch 1 not taken.
1648 if(!p_igetl(&tmp2,f))
21002 return qe_invalid;
21003
1/2
✓ Branch 0 taken 1648 times.
✗ Branch 1 not taken.
1648 if(!p_igetl(&tmp3,f))
21004 return qe_invalid;
21005
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 1648 times.
1648 if(q < MAX_COMBO_COLS)
21006 {
21007 1648 First[q] = tmp;
21008 1648 combo_alistpos[q] = tmp2;
21009 1648 combo_pool_listpos[q] = tmp3;
21010 1648 }
21011 1648 }
21012
21013
1/2
✓ Branch 0 taken 412 times.
✗ Branch 1 not taken.
412 if(!p_igetw(&max_mappages,f))
21014 return qe_invalid;
21015
2/2
✓ Branch 0 taken 3708 times.
✓ Branch 1 taken 412 times.
4120 for(int q = 0; q < max_mappages; ++q)
21016 {
21017
1/2
✓ Branch 0 taken 3708 times.
✗ Branch 1 not taken.
3708 if(!p_igetl(&tmp,f))
21018 return qe_invalid;
21019
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3708 times.
3708 if(!p_igetl(&tmp2,f))
21020 return qe_invalid;
21021
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3708 times.
3708 if(q < MAX_MAPPAGE_BTNS)
21022 {
21023 3708 map_page[q].map = tmp;
21024 3708 map_page[q].screen = tmp2;
21025 3708 }
21026 3708 }
21027 412 }
21028
21029
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if (should_skip)
21030 return 0;
21031
21032
2/2
✓ Branch 0 taken 800 times.
✓ Branch 1 taken 612 times.
1412 for(int q = max_combo_cols; q < MAX_COMBO_COLS; ++q)
21033 {
21034 800 First[q] = 0;
21035 800 combo_alistpos[q] = 0;
21036 800 combo_pool_listpos[q] = 0;
21037 800 }
21038
2/2
✓ Branch 0 taken 1800 times.
✓ Branch 1 taken 612 times.
2412 for(int q = max_mappages; q < MAX_MAPPAGE_BTNS; ++q)
21039 {
21040 1800 map_page[q].map = 0;
21041 1800 map_page[q].screen = 0;
21042 1800 }
21043
21044 612 return 0;
21045 612 }
21046
21047 /*
21048 switch (ret) {
21049 case 0:
21050 break;
21051
21052 case qe_invalid:
21053 goto invalid;
21054 break;
21055 default:
21056 pack_fclose(f);
21057 if(!oldquest)
21058 delete_file(tmpfilename);
21059 return ret;
21060 break;
21061 }
21062 */
21063
21064 const char *skip_text[skip_max]=
21065 {
21066 "skip_header", "skip_rules", "skip_strings", "skip_misc",
21067 "skip_tiles", "skip_combos", "skip_comboaliases", "skip_csets",
21068 "skip_maps", "skip_dmaps", "skip_doors", "skip_items",
21069 "skip_weapons", "skip_colors", "skip_icons", "skip_initdata",
21070 "skip_guys", "skip_herosprites", "skip_subscreens", "skip_ffscript",
21071 "skip_sfx", "skip_midis", "skip_cheats", "skip_itemdropsets",
21072 "skip_favorites"
21073 };
21074
21075
21076 void port250QuestRules(){
21077
21078 portCandleRules(); //Candle
21079 portBombRules();
21080
21081 }
21082
21083 void portCandleRules()
21084 {
21085 bool hurtshero = get_qr(qr_FIREPROOFHERO);
21086 //itemdata itemsbuf;
21087 for ( int32_t q = 0; q < MAXITEMS; q++ )
21088 {
21089 if ( itemsbuf[q].family == itype_candle )
21090 {
21091 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21092 else itemsbuf[q].flags &= ~ item_flag2;
21093 }
21094 }
21095 }
21096
21097 void portBombRules()
21098 {
21099 bool hurtshero = get_qr(qr_OUCHBOMBS);
21100 //itemdata itemsbuf;
21101 for ( int32_t q = 0; q < MAXITEMS; q++ )
21102 {
21103 if ( itemsbuf[q].family == itype_bomb )
21104 {
21105 if ( hurtshero ) itemsbuf[q].flags |= item_flag2;
21106 else itemsbuf[q].flags &= ~ item_flag2;
21107 }
21108 }
21109 }
21110
21111 15981 static int section_id_to_enum(int id)
21112 {
21113
24/27
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✓ Branch 2 taken 695 times.
✓ Branch 3 taken 695 times.
✓ Branch 4 taken 695 times.
✓ Branch 5 taken 695 times.
✓ Branch 6 taken 612 times.
✓ Branch 7 taken 695 times.
✓ Branch 8 taken 695 times.
✓ Branch 9 taken 695 times.
✓ Branch 10 taken 695 times.
✓ Branch 11 taken 695 times.
✓ Branch 12 taken 695 times.
✓ Branch 13 taken 612 times.
✓ Branch 14 taken 612 times.
✓ Branch 15 taken 695 times.
✓ Branch 16 taken 695 times.
✓ Branch 17 taken 636 times.
✓ Branch 18 taken 612 times.
✓ Branch 19 taken 612 times.
✓ Branch 20 taken 612 times.
✓ Branch 21 taken 695 times.
✓ Branch 22 taken 695 times.
✓ Branch 23 taken 636 times.
✓ Branch 24 taken 612 times.
✗ Branch 25 not taken.
✗ Branch 26 not taken.
15981 switch (id)
21114 {
21115 case ID_HEADER: return skip_header;
21116 695 case ID_RULES: return skip_rules;
21117 695 case ID_STRINGS: return skip_strings;
21118 695 case ID_MISC: return skip_misc;
21119 695 case ID_TILES: return skip_tiles;
21120 695 case ID_COMBOS: return skip_combos;
21121 612 case ID_COMBOALIASES: return skip_comboaliases;
21122 695 case ID_CSETS: return skip_csets;
21123 695 case ID_MAPS: return skip_maps;
21124 695 case ID_DMAPS: return skip_dmaps;
21125 695 case ID_DOORS: return skip_doors;
21126 695 case ID_ITEMS: return skip_items;
21127 695 case ID_WEAPONS: return skip_weapons;
21128 612 case ID_COLORS: return skip_colors;
21129 612 case ID_ICONS: return skip_icons;
21130 695 case ID_INITDATA: return skip_initdata;
21131 695 case ID_GUYS: return skip_guys;
21132 636 case ID_HEROSPRITES: return skip_herosprites;
21133 612 case ID_SUBSCREEN: return skip_subscreens;
21134 612 case ID_FFSCRIPT: return skip_ffscript;
21135 612 case ID_SFX: return skip_sfx;
21136 695 case ID_MIDIS: return skip_midis;
21137 695 case ID_CHEATS: return skip_cheats;
21138 636 case ID_ITEMDROPSETS: return skip_itemdropsets;
21139 612 case ID_FAVORITES: return skip_favorites;
21140 case ID_ZINFO: return skip_zinfo;
21141 }
21142
21143 return -1;
21144 15981 }
21145
21146 15573 static int maybe_skip_section(PACKFILE* f, dword& section_id, const byte* skip_flags)
21147 {
21148 15573 int section_enum = section_id_to_enum(section_id);
21149
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15573 times.
15573 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21150
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 15573 times.
15573 if (skip)
21151 {
21152 word s_version;
21153 if (!p_igetw(&s_version,f))
21154 {
21155 return qe_invalid;
21156 }
21157
21158 word c_version;
21159 if (!p_igetw(&c_version,f))
21160 {
21161 return qe_invalid;
21162 }
21163
21164 if (section_id == ID_RULES && s_version > 16)
21165 {
21166 dword dummy;
21167 if (!p_igetl(&dummy,f))
21168 {
21169 return qe_invalid;
21170 }
21171 }
21172
21173 if (section_id == ID_FFSCRIPT && s_version >= 18)
21174 {
21175 word dummy;
21176 if (!p_igetw(&dummy,f))
21177 {
21178 return qe_invalid;
21179 }
21180 }
21181
21182 dword section_length;
21183 if (!p_igetl(&section_length,f))
21184 {
21185 return qe_invalid;
21186 }
21187
21188 if (pack_fseek(f, section_length))
21189 {
21190 return qe_invalid;
21191 }
21192
21193 if (!pack_feof(f))
21194 {
21195 if (!p_mgetl(&section_id,f))
21196 {
21197 return qe_invalid;
21198 }
21199 }
21200
21201 return qe_cancel;
21202 }
21203
21204 15573 return qe_OK;
21205 15573 }
21206
21207 //Internal function for loadquest wrapper
21208 695 static int32_t _lq_int(const char *filename, zquestheader *Header, miscQdata *Misc, zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata)
21209 {
21210 695 DMapEditorLastMaptileUsed = 0;
21211 695 combosread=false;
21212 695 mapsread=false;
21213 695 fixffcs=false;
21214
21215 695 bool do_clear_scripts = !get_bit(skip_flags,skip_ffscript);
21216
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 if(loading_tileset_flags & TILESET_CLEARSCRIPTS)
21217 {
21218 set_bit(skip_flags, skip_ffscript, 1);
21219 setZScriptVersion(V_FFSCRIPT);
21220 FFCore.quest_format[vFFScript] = V_FFSCRIPT;
21221 FFCore.quest_format[vLastCompile] = V_FFSCRIPT;
21222 do_clear_scripts = true;
21223 }
21224
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 if(loading_tileset_flags & TILESET_CLEARMAPS)
21225 {
21226 set_bit(skip_flags, skip_maps, 1);
21227 }
21228
21229 // show_progress=true;
21230 char tmpfilename[L_tmpnam];
21231 695 temp_name(tmpfilename);
21232 // char percent_done[30];
21233 695 bool catchup=false;
21234 byte tempbyte;
21235 695 word old_map_count=map_count;
21236
21237 695 byte old_quest_rules[QUESTRULES_NEW_SIZE] = {0};
21238 695 byte old_extra_rules[EXTRARULES_SIZE] = {0};
21239 695 byte old_midi_flags[MIDIFLAGS_SIZE] = {0};
21240
21241
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 694 times.
695 if(get_bit(skip_flags, skip_rules))
21242 {
21243 1 memcpy(old_quest_rules, quest_rules, QUESTRULES_NEW_SIZE);
21244 1 memcpy(old_extra_rules, extra_rules, EXTRARULES_SIZE);
21245 1 }
21246
21247 695 memset(quest_rules, 0, QUESTRULES_NEW_SIZE); //clear here to prevent any kind of carryover -Z
21248 695 unpack_qrs();
21249 // memset(extra_rules, 0, EXTRARULES_SIZE); //clear here to prevent any kind of carryover -Z
21250
21251
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 694 times.
695 if(get_bit(skip_flags, skip_midis))
21252 {
21253 1 memcpy(old_midi_flags, midi_flags, MIDIFLAGS_SIZE);
21254 1 }
21255
21256
21257
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 694 times.
695 if(do_clear_scripts)
21258 {
21259 694 zScript.clear();
21260 694 globalmap.clear();
21261 694 genericmap.clear();
21262 694 ffcmap.clear();
21263 694 itemmap.clear();
21264 694 npcmap.clear();
21265 694 ewpnmap.clear();
21266 694 lwpnmap.clear();
21267 694 playermap.clear();
21268 694 dmapmap.clear();
21269 694 screenmap.clear();
21270 694 itemspritemap.clear();
21271 694 comboscriptmap.clear();
21272 694 subscreenmap.clear();
21273
21274
2/2
✓ Branch 0 taken 354634 times.
✓ Branch 1 taken 694 times.
355328 for(int32_t i=0; i<NUMSCRIPTFFC-1; i++)
21275 {
21276 354634 ffcmap[i].clear();
21277 354634 }
21278
21279 694 globalmap[0].slotname = "Slot 1:";
21280 694 globalmap[0].scriptname = "~Init";
21281 694 globalmap[0].update();
21282
21283
2/2
✓ Branch 0 taken 4858 times.
✓ Branch 1 taken 694 times.
5552 for(int32_t i=1; i<NUMSCRIPTGLOBAL; i++)
21284 {
21285 4858 globalmap[i].clear();
21286 4858 }
21287
21288
2/2
✓ Branch 0 taken 176970 times.
✓ Branch 1 taken 694 times.
177664 for(int32_t i=0; i<NUMSCRIPTITEM-1; i++)
21289 {
21290 176970 itemmap[i].clear();
21291 176970 }
21292
21293 //new script types -- prevent carrying over to a quest that you load after reading them
21294 //e.g., a quest has an npc script, and you make a blank quest, that now believes that it has an npc script, too!
21295
2/2
✓ Branch 0 taken 176970 times.
✓ Branch 1 taken 694 times.
177664 for(int32_t i=0; i<NUMSCRIPTGUYS-1; i++)
21296 {
21297 176970 npcmap[i].clear();
21298 176970 }
21299
2/2
✓ Branch 0 taken 176970 times.
✓ Branch 1 taken 694 times.
177664 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21300 {
21301 176970 lwpnmap[i].clear();
21302 176970 }
21303
2/2
✓ Branch 0 taken 176970 times.
✓ Branch 1 taken 694 times.
177664 for(int32_t i=0; i<NUMSCRIPTWEAPONS-1; i++)
21304 {
21305 176970 ewpnmap[i].clear();
21306 176970 }
21307
2/2
✓ Branch 0 taken 2776 times.
✓ Branch 1 taken 694 times.
3470 for(int32_t i=0; i<NUMSCRIPTPLAYER-1; i++)
21308 {
21309 2776 playermap[i].clear();
21310 2776 }
21311
2/2
✓ Branch 0 taken 176970 times.
✓ Branch 1 taken 694 times.
177664 for(int32_t i=0; i<NUMSCRIPTSDMAP-1; i++)
21312 {
21313 176970 dmapmap[i].clear();
21314 176970 }
21315
2/2
✓ Branch 0 taken 176970 times.
✓ Branch 1 taken 694 times.
177664 for(int32_t i=0; i<NUMSCRIPTSCREEN-1; i++)
21316 {
21317 176970 screenmap[i].clear();
21318 176970 }
21319
2/2
✓ Branch 0 taken 176970 times.
✓ Branch 1 taken 694 times.
177664 for(int32_t i=0; i<NUMSCRIPTSITEMSPRITE-1; i++)
21320 {
21321 176970 itemspritemap[i].clear();
21322 176970 }
21323
2/2
✓ Branch 0 taken 354634 times.
✓ Branch 1 taken 694 times.
355328 for(int32_t i=0; i<NUMSCRIPTSCOMBODATA-1; i++)
21324 {
21325 354634 comboscriptmap[i].clear();
21326 354634 }
21327
2/2
✓ Branch 0 taken 354634 times.
✓ Branch 1 taken 694 times.
355328 for(int32_t i=0; i<NUMSCRIPTSGENERIC-1; i++)
21328 {
21329 354634 genericmap[i].clear();
21330 354634 }
21331
2/2
✓ Branch 0 taken 176970 times.
✓ Branch 1 taken 694 times.
177664 for(int32_t i=0; i<NUMSCRIPTSSUBSCREEN-1; i++)
21332 {
21333 176970 subscreenmap[i].clear();
21334 176970 }
21335
21336 694 reset_scripts();
21337 694 }
21338
21339 zquestheader tempheader;
21340 695 memset(&tempheader, 0, sizeof(zquestheader));
21341 695 zinfo tempzi;
21342 695 tempzi.clear();
21343 695 load_tmp_zi = &tempzi;
21344
21345 // oldquest flag is set when an unencrypted qst file is suspected.
21346 695 bool oldquest = false;
21347 695 int32_t open_error=0;
21348 695 PACKFILE *f=open_quest_file(&open_error, filename, show_progress);
21349
21350
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 if (!f)
21351 {
21352 ASSERT(open_error != 0);
21353 return open_error;
21354 }
21355 char zinfofilename[2048];
21356 695 replace_extension(zinfofilename, filename, "zinfo", 2047);
21357 695 int32_t ret=0;
21358
21359 //header
21360 695 box_out("Reading Header...");
21361 695 ret=readheader(f, &tempheader, printmetadata);
21362
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
695 checkstatus(ret);
21363 695 box_out("okay.");
21364 695 box_eol();
21365
21366
2/2
✓ Branch 0 taken 272 times.
✓ Branch 1 taken 423 times.
695 if(read_zinfo)
21367 {
21368 423 box_out("Reading ZInfo - ");
21369
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 420 times.
423 box_out(read_ext_zinfo ? "External..." : "Internal...");
21370
2/2
✓ Branch 0 taken 3 times.
✓ Branch 1 taken 420 times.
423 if(read_ext_zinfo)
21371 {
21372 3 PACKFILE *inf=pack_fopen_password(zinfofilename, F_READ, "");
21373 3 ret=readzinfo(inf, tempzi, tempheader);
21374
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
3 if(inf) pack_fclose(inf);
21375
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 3 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
3 checkstatus(ret);
21376 3 }
21377 else
21378 {
21379 420 ret=readzinfo(f, tempzi, tempheader);
21380
1/5
✗ Branch 0 not taken.
✓ Branch 1 taken 420 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
420 checkstatus(ret);
21381 }
21382 423 box_out("okay.");
21383 423 box_eol();
21384 423 }
21385
21386
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 if(tempheader.zelda_version>=0x193)
21387 {
21388 dword section_id;
21389
21390 //section id
21391
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 if(!p_mgetl(&section_id,f))
21392 {
21393 goto invalid;
21394 }
21395
21396 671 std::set<dword> seen_sections;
21397
21398
3/4
✓ Branch 0 taken 16244 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15573 times.
✓ Branch 3 taken 671 times.
16244 while(!pack_feof(f))
21399 {
21400
2/4
✓ Branch 0 taken 15573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15573 times.
✗ Branch 3 not taken.
15573 if (seen_sections.contains(section_id))
21401 goto invalid;
21402
1/2
✓ Branch 0 taken 15573 times.
✗ Branch 1 not taken.
15573 seen_sections.insert(section_id);
21403
21404
2/4
✓ Branch 0 taken 15573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 15573 times.
✗ Branch 3 not taken.
15573 if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21405 {
21406 if (retval == qe_cancel)
21407 continue;
21408 checkstatus(retval);
21409 }
21410
21411
24/25
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 671 times.
✓ Branch 2 taken 671 times.
✓ Branch 3 taken 671 times.
✓ Branch 4 taken 671 times.
✓ Branch 5 taken 612 times.
✓ Branch 6 taken 671 times.
✓ Branch 7 taken 671 times.
✓ Branch 8 taken 671 times.
✓ Branch 9 taken 671 times.
✓ Branch 10 taken 671 times.
✓ Branch 11 taken 671 times.
✓ Branch 12 taken 612 times.
✓ Branch 13 taken 612 times.
✓ Branch 14 taken 671 times.
✓ Branch 15 taken 671 times.
✓ Branch 16 taken 612 times.
✓ Branch 17 taken 612 times.
✓ Branch 18 taken 612 times.
✓ Branch 19 taken 612 times.
✓ Branch 20 taken 671 times.
✓ Branch 21 taken 671 times.
✓ Branch 22 taken 612 times.
✓ Branch 23 taken 612 times.
✗ Branch 24 not taken.
15573 switch(section_id)
21412 {
21413 case ID_RULES:
21414
21415 //rules
21416
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21417 {
21418 box_out("found.");
21419 box_eol();
21420 catchup=false;
21421 }
21422
21423
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Rules...");
21424
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readrules(f, &tempheader);
21425
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21426
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21427
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21428 671 break;
21429
21430 case ID_STRINGS:
21431
21432 //strings
21433
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21434 {
21435 box_out("found.");
21436 box_eol();
21437 catchup=false;
21438 }
21439
21440
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Strings...");
21441
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readstrings(f, &tempheader);
21442
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21443
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21444
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21445 671 break;
21446
21447 case ID_MISC:
21448
21449 //misc data
21450
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21451 {
21452 box_out("found.");
21453 box_eol();
21454 catchup=false;
21455 }
21456
21457
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Misc. Data...");
21458
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readmisc(f, &tempheader, Misc);
21459
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21460
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21461
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21462 671 break;
21463
21464 case ID_TILES:
21465
21466 //tiles
21467
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21468 {
21469 box_out("found.");
21470 box_eol();
21471 catchup=false;
21472 }
21473
21474
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Tiles...");
21475
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false);
21476
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21477
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21478
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21479 671 break;
21480
21481 case ID_COMBOS:
21482
21483 //combos
21484
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21485 {
21486 box_out("found.");
21487 box_eol();
21488 catchup=false;
21489 }
21490
21491
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Combos...");
21492
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS);
21493 671 combosread=true;
21494
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21495
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21496
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21497 671 break;
21498
21499 case ID_COMBOALIASES:
21500
21501 //combo aliases
21502
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(catchup)
21503 {
21504 box_out("found.");
21505 box_eol();
21506 catchup=false;
21507 }
21508
21509
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("Reading Combo Aliases...");
21510
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 ret=readcomboaliases(f, &tempheader, tempheader.zelda_version, tempheader.build);
21511
1/9
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
612 checkstatus(ret);
21512
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("okay.");
21513
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_eol();
21514 612 break;
21515
21516 case ID_CSETS:
21517
21518 //color data
21519
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21520 {
21521 box_out("found.");
21522 box_eol();
21523 catchup=false;
21524 }
21525
21526
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Color Data...");
21527
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL);
21528
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21529
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21530
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21531 671 break;
21532
21533 case ID_MAPS:
21534
21535 //maps
21536
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21537 {
21538 box_out("found.");
21539 box_eol();
21540 catchup=false;
21541 }
21542
21543
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Maps...");
21544
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readmaps(f, &tempheader);
21545 671 mapsread=true;
21546
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21547
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21548
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21549 671 break;
21550
21551 case ID_DMAPS:
21552
21553 //dmaps
21554
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21555 {
21556 box_out("found.");
21557 box_eol();
21558 catchup=false;
21559 }
21560
21561
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading DMaps...");
21562
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS);
21563
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21564
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21565
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21566 671 break;
21567
21568 case ID_DOORS:
21569
21570 //door combo sets
21571
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21572 {
21573 box_out("found.");
21574 box_eol();
21575 catchup=false;
21576 }
21577
21578
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Doors...");
21579
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readdoorcombosets(f, &tempheader);
21580
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21581
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21582
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21583 671 break;
21584
21585 case ID_ITEMS:
21586
21587 //items
21588
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21589 {
21590 box_out("found.");
21591 box_eol();
21592 catchup=false;
21593 }
21594
21595
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Items...");
21596
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readitems(f, tempheader.zelda_version, tempheader.build);
21597
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21598
21599
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21600
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21601 671 break;
21602
21603 case ID_WEAPONS:
21604
21605 //weapons
21606
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21607 {
21608 box_out("found.");
21609 box_eol();
21610 catchup=false;
21611 }
21612
21613
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Weapons...");
21614
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readweapons(f, &tempheader);
21615
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21616
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21617
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21618 671 break;
21619
21620 case ID_COLORS:
21621
21622 //misc. colors
21623
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(catchup)
21624 {
21625 box_out("found.");
21626 box_eol();
21627 catchup=false;
21628 }
21629
21630
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("Reading Misc. Colors...");
21631
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 ret=readmisccolors(f, &tempheader, Misc);
21632
1/9
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
612 checkstatus(ret);
21633
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("okay.");
21634
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_eol();
21635 612 break;
21636
21637 case ID_ICONS:
21638
21639 //game icons
21640
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(catchup)
21641 {
21642 box_out("found.");
21643 box_eol();
21644 catchup=false;
21645 }
21646
21647
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("Reading Game Icons...");
21648
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 ret=readgameicons(f, &tempheader, Misc);
21649
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
612 checkstatus(ret);
21650
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("okay.");
21651
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_eol();
21652 612 break;
21653
21654 case ID_INITDATA:
21655
21656 //initialization data
21657
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21658 {
21659 box_out("found.");
21660 box_eol();
21661 catchup=false;
21662 }
21663
21664
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Init. Data...");
21665
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readinitdata(f, &tempheader);
21666
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21667
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21668
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21669
21670
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 671 times.
671 if(!get_bit(skip_flags, skip_subscreens))
21671 {
21672
2/2
✓ Branch 0 taken 84 times.
✓ Branch 1 taken 587 times.
671 if(subscr_mode!=ssdtMAX) //not using custom subscreens
21673 {
21674
1/2
✓ Branch 0 taken 84 times.
✗ Branch 1 not taken.
84 setupsubscreens();
21675
21676
2/2
✓ Branch 0 taken 43008 times.
✓ Branch 1 taken 84 times.
43092 for(int32_t i=0; i<MAXDMAPS; ++i)
21677 {
21678 43008 int32_t type=DMaps[i].type&dmfTYPE;
21679
2/2
✓ Branch 0 taken 1076 times.
✓ Branch 1 taken 41932 times.
43008 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21680 43008 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21681 43008 }
21682 84 }
21683 671 }
21684
21685
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 671 times.
671 if(!get_bit(skip_flags, skip_sfx))
21686 {
21687 671 setupsfx();
21688 671 }
21689
21690
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 671 times.
✗ Branch 3 not taken.
671 if(!get_bit(skip_flags, skip_itemdropsets))
21691 {
21692
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 init_item_drop_sets();
21693 671 }
21694
21695
2/4
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✓ Branch 3 taken 671 times.
671 if(!get_bit(skip_flags, skip_favorites))
21696 {
21697 671 init_favorites();
21698 671 }
21699
21700 671 break;
21701
21702 case ID_GUYS:
21703
21704 //guys
21705
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21706 {
21707 box_out("found.");
21708 box_eol();
21709 catchup=false;
21710 }
21711
21712
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Custom Guy Data...");
21713
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readguys(f, &tempheader);
21714
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21715
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21716
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21717 671 break;
21718
21719 case ID_HEROSPRITES:
21720
21721 //player sprites
21722
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(catchup)
21723 {
21724 box_out("found.");
21725 box_eol();
21726 catchup=false;
21727 }
21728
21729
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("Reading Custom Player Sprite Data...");
21730
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 ret=readherosprites(f, &tempheader);
21731
1/9
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
612 checkstatus(ret);
21732
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("okay.");
21733
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_eol();
21734 612 break;
21735
21736 case ID_SUBSCREEN:
21737
21738 //custom subscreens
21739
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(catchup)
21740 {
21741 box_out("found.");
21742 box_eol();
21743 catchup=false;
21744 }
21745
21746
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("Reading Custom Subscreen Data...");
21747
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 ret=readsubscreens(f);
21748
1/9
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
612 checkstatus(ret);
21749
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("okay.");
21750
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_eol();
21751 612 break;
21752
21753 case ID_FFSCRIPT:
21754
21755 //Freeform combo scripts
21756
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(catchup)
21757 {
21758 box_out("found.");
21759 box_eol();
21760 catchup=false;
21761 }
21762
21763
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("Reading FF Script Data...");
21764
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 ret=readffscript(f, &tempheader);
21765
1/9
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
612 checkstatus(ret);
21766
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("okay.");
21767
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_eol();
21768 612 break;
21769
21770 case ID_SFX:
21771
21772 //SFX data
21773
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(catchup)
21774 {
21775 box_out("found.");
21776 box_eol();
21777 catchup=false;
21778 }
21779
21780
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("Reading SFX Data...");
21781
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 ret=readsfx(f, &tempheader);
21782
1/9
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
612 checkstatus(ret);
21783
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("okay.");
21784
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_eol();
21785 612 break;
21786
21787 case ID_MIDIS:
21788
21789 //midis
21790
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21791 {
21792 box_out("found.");
21793 box_eol();
21794 catchup=false;
21795 }
21796
21797
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Tunes...");
21798
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readtunes(f, &tempheader, tunes);
21799
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21800
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21801
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21802 671 break;
21803
21804 case ID_CHEATS:
21805
21806 //cheat codes
21807
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 if(catchup)
21808 {
21809 box_out("found.");
21810 box_eol();
21811 catchup=false;
21812 }
21813
21814
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("Reading Cheat Codes...");
21815
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 ret=readcheatcodes(f, &tempheader);
21816
1/9
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
671 checkstatus(ret);
21817
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_out("okay.");
21818
1/2
✓ Branch 0 taken 671 times.
✗ Branch 1 not taken.
671 box_eol();
21819 671 break;
21820
21821 case ID_ITEMDROPSETS:
21822
21823 //item drop sets
21824
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(catchup)
21825 {
21826 box_out("found.");
21827 box_eol();
21828 catchup=false;
21829 }
21830
21831
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("Reading Item Drop Sets...");
21832
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 ret=readitemdropsets(f, tempheader.zelda_version, tempheader.build);
21833
1/9
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
612 checkstatus(ret);
21834
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("okay.");
21835
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_eol();
21836 612 break;
21837
21838 case ID_FAVORITES:
21839
21840 //favorite combos and combo aliases
21841
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 612 times.
612 if(catchup)
21842 {
21843 box_out("found.");
21844 box_eol();
21845 catchup=false;
21846 }
21847
21848
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("Reading Favorite Combos...");
21849
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 ret=readfavorites(f, tempheader.zelda_version, tempheader.build);
21850
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 612 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
612 checkstatus(ret);
21851
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_out("okay.");
21852
1/2
✓ Branch 0 taken 612 times.
✗ Branch 1 not taken.
612 box_eol();
21853 612 break;
21854
21855 default:
21856 if(!catchup)
21857 {
21858 box_out("Bad token! Searching...");
21859 box_eol();
21860 }
21861
21862 catchup=true;
21863 break;
21864 }
21865
21866
21867
1/2
✓ Branch 0 taken 15573 times.
✗ Branch 1 not taken.
15573 if(catchup)
21868 {
21869 //section id
21870 section_id=(section_id<<8);
21871
21872 if(!p_getc(&tempbyte,f))
21873 {
21874 goto invalid;
21875 }
21876
21877 section_id+=tempbyte;
21878 }
21879
21880 else
21881 {
21882 //section id
21883
3/4
✓ Branch 0 taken 15573 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14902 times.
✓ Branch 3 taken 671 times.
15573 if(!pack_feof(f))
21884 {
21885
2/4
✓ Branch 0 taken 14902 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 14902 times.
✗ Branch 3 not taken.
14902 if(!p_mgetl(&section_id,f))
21886 {
21887 goto invalid;
21888 }
21889 14902 }
21890 }
21891 }
21892
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 671 times.
671 }
21893 else
21894 {
21895
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 std::vector<std::tuple<std::string, int32_t, std::function<int32_t()>>> hardcoded_sections = {
21896
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Rules", ID_RULES, [&](){ return readrules(f, &tempheader); }},
21897
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Strings", ID_STRINGS, [&](){ return readstrings(f, &tempheader); }},
21898
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Doors", ID_DOORS, [&](){ return readdoorcombosets(f, &tempheader); }},
21899
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "DMaps", ID_DMAPS, [&](){ return readdmaps(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXDMAPS); }},
21900
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Misc. Data", ID_MISC, [&](){ return readmisc(f, &tempheader, Misc); }},
21901
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Items", ID_ITEMS, [&](){ return readitems(f, tempheader.zelda_version, tempheader.build); }},
21902
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Weapons", ID_WEAPONS, [&](){ return readweapons(f, &tempheader); }},
21903
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Guy Data", ID_GUYS, [&](){ return readguys(f, &tempheader); }},
21904
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Maps", ID_MAPS, [&](){ return readmaps(f, &tempheader); }},
21905
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Combos", ID_COMBOS, [&](){ return readcombos(f, &tempheader, tempheader.zelda_version, tempheader.build, 0, MAXCOMBOS); }},
21906
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Color Data", ID_CSETS, [&](){ return readcolordata(f, Misc, tempheader.zelda_version, tempheader.build, 0, newerpdTOTAL); }},
21907
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
48 { "Tiles", ID_TILES, [&](){ return readtiles(f, newtilebuf, &tempheader, tempheader.zelda_version, tempheader.build, 0, NEWMAXTILES, false); }},
21908
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Tunes", ID_MIDIS, [&](){ return readtunes(f, &tempheader, tunes); }},
21909
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Cheat Codes", ID_CHEATS, [&](){ return readcheatcodes(f, &tempheader); }},
21910
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Init. Data", ID_INITDATA, [&](){ return readinitdata(f, &tempheader); }},
21911
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Custom Player Sprite Data", ID_HEROSPRITES, [&](){ return readherosprites2(f, -1, 0); }},
21912
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
47 { "Up Default Item Drop Sets", ID_ITEMDROPSETS, [&](){ return readitemdropsets(f, -1, 0); }},
21913 };
21914
21915 24 legacy_skip_flags = skip_flags;
21916
2/2
✓ Branch 0 taken 24 times.
✓ Branch 1 taken 408 times.
1250 for (auto& [desc, section_id, fn] : hardcoded_sections)
21917 {
21918
1/2
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
408 int section_enum = section_id_to_enum(section_id);
21919
2/4
✓ Branch 0 taken 408 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 408 times.
✗ Branch 3 not taken.
408 bool skip = section_enum >= 0 && get_bit(skip_flags, section_enum);
21920
2/2
✓ Branch 0 taken 392 times.
✓ Branch 1 taken 16 times.
408 if (skip)
21921 {
21922 // Nothing to read.
21923
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 15 times.
16 if (section_id == ID_RULES)
21924 1 continue;
21925
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 14 times.
15 if (section_id == ID_GUYS)
21926 1 continue;
21927
21928 // Haven't looked at how to skip these, because we don't need to currently: the only
21929 // usage of skip_flags currently is all off except: header and tiles (see `load_imagebuf`).
21930
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 13 times.
14 if (section_id == ID_MIDIS)
21931 1 continue;
21932
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 12 times.
13 if (section_id == ID_CHEATS)
21933 1 continue;
21934
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 11 times.
12 if (section_id == ID_INITDATA)
21935 1 continue;
21936
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 10 times.
11 if (section_id == ID_HEROSPRITES)
21937 1 continue;
21938
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 9 times.
10 if (section_id == ID_ITEMDROPSETS)
21939 1 continue;
21940 9 }
21941
21942 // Would be nice, but old sections mostly did not save section sizes. We could advance by
21943 // a specific amount, but it'd be a lot of work to get it right. So, for old quests, let's just
21944 // read all the sections even if requested to skip some.
21945 // if (int retval = maybe_skip_section(f, section_id, skip_flags); retval != qe_OK)
21946 // {
21947 // if (retval == qe_cancel)
21948 // continue;
21949 // checkstatus(retval);
21950 // }
21951
21952
3/6
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✓ Branch 4 taken 401 times.
✗ Branch 5 not taken.
802 box_out(fmt::format("Reading {}...", desc).c_str());
21953
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 ret = fn();
21954
1/9
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 401 times.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✗ Branch 8 not taken.
401 checkstatus(ret);
21955
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_out("okay.");
21956
1/2
✓ Branch 0 taken 401 times.
✗ Branch 1 not taken.
401 box_eol();
21957 }
21958 24 legacy_skip_flags = nullptr;
21959
21960
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 23 times.
✓ Branch 3 taken 1 times.
24 if(!get_bit(skip_flags, skip_subscreens))
21961 {
21962
1/2
✓ Branch 0 taken 23 times.
✗ Branch 1 not taken.
23 setupsubscreens();
21963
21964
2/2
✓ Branch 0 taken 11776 times.
✓ Branch 1 taken 23 times.
11799 for(int32_t i=0; i<MAXDMAPS; ++i)
21965 {
21966 11776 int32_t type=DMaps[i].type&dmfTYPE;
21967
2/2
✓ Branch 0 taken 44 times.
✓ Branch 1 taken 11732 times.
11776 DMaps[i].active_subscreen=(type == dmOVERW || type == dmBSOVERW)?0:1;
21968 11776 DMaps[i].passive_subscreen=(get_qr(qr_ENABLEMAGIC))?0:1;
21969 11776 }
21970 23 }
21971
21972
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("Setting Up Default Sound Effects...");
21973
21974
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_sfx))
21975 23 setupsfx();
21976
21977
3/4
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
✓ Branch 2 taken 1 times.
✓ Branch 3 taken 23 times.
24 if(!get_bit(skip_flags, skip_favorites))
21978 23 init_favorites();
21979
21980
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_out("okay.");
21981
1/2
✓ Branch 0 taken 24 times.
✗ Branch 1 not taken.
24 box_eol();
21982
1/3
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 24 times.
24 }
21983
21984 695 init_spritelists();
21985
21986 // check data
21987
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 if(f)
21988 {
21989 695 pack_fclose(f);
21990 695 }
21991 695 clear_quest_tmpfile();
21992
21993
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 if(!oldquest)
21994 {
21995
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 if(exists(tmpfilename))
21996 {
21997 delete_file(tmpfilename);
21998 }
21999 695 }
22000
22001
1/6
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
✗ Branch 2 not taken.
✗ Branch 3 not taken.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
695 if(fixffcs && combosread && mapsread)
22002 {
22003 for(int32_t i=0; i<map_count; i++)
22004 {
22005 for(int32_t j=0; j<MAPSCRS; j++)
22006 {
22007 for(int32_t m=0; m<32; m++)
22008 {
22009 if(combobuf[TheMaps[(i*MAPSCRS)+j].ffcs[m].data].type == cCHANGE)
22010 TheMaps[(i*MAPSCRS)+j].ffcs[m].flags|=ffc_changer;
22011 }
22012 }
22013 }
22014 }
22015
22016
5/6
✓ Branch 0 taken 60 times.
✓ Branch 1 taken 635 times.
✓ Branch 2 taken 59 times.
✓ Branch 3 taken 1 times.
✓ Branch 4 taken 59 times.
✗ Branch 5 not taken.
695 if(get_qr(qr_CONTFULL_DEP) && !get_bit(skip_flags, skip_rules) && !get_bit(skip_flags, skip_initdata))
22017 {
22018 59 set_qr(qr_CONTFULL_DEP, 0);
22019 59 zinit.flags.set(INIT_FL_CONTPERCENT,true);
22020 59 zinit.cont_heart=100;
22021 59 zinit.counter[crLIFE]=zinit.mcounter[crLIFE];
22022 59 }
22023
22024 695 box_out("Done.");
22025 695 box_eol();
22026 695 box_end(false);
22027
22028
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 695 times.
695 if(!get_bit(skip_flags, skip_header))
22029 {
22030 695 memcpy(Header, &tempheader, sizeof(tempheader));
22031 695 }
22032
2/2
✓ Branch 0 taken 1 times.
✓ Branch 1 taken 694 times.
695 if(!get_bit(skip_flags, skip_zinfo))
22033 {
22034 694 ZI.copyFrom(tempzi);
22035 694 }
22036
22037
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 1 times.
695 if(get_bit(skip_flags, skip_maps))
22038 {
22039 1 map_count=old_map_count;
22040 1 }
22041
22042
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 1 times.
695 if(get_bit(skip_flags, skip_rules))
22043 {
22044 1 memcpy(quest_rules, old_quest_rules, QUESTRULES_NEW_SIZE);
22045 1 memcpy(extra_rules, old_extra_rules, EXTRARULES_SIZE);
22046 1 unpack_qrs();
22047 1 }
22048
22049
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 1 times.
695 if(get_bit(skip_flags, skip_midis))
22050 {
22051 1 memcpy(midi_flags, old_midi_flags, MIDIFLAGS_SIZE);
22052 1 }
22053
22054
2/2
✓ Branch 0 taken 671 times.
✓ Branch 1 taken 24 times.
695 if( FFCore.quest_format[vZelda] < 0x210 )
22055 {
22056 24 zprint2("\n[QUEST METADATA]\n");
22057
22058
3/13
✗ Branch 0 not taken.
✗ Branch 1 not taken.
✓ Branch 2 taken 6 times.
✓ Branch 3 taken 12 times.
✗ Branch 4 not taken.
✗ Branch 5 not taken.
✗ Branch 6 not taken.
✗ Branch 7 not taken.
✓ Branch 8 taken 6 times.
✗ Branch 9 not taken.
✗ Branch 10 not taken.
✗ Branch 11 not taken.
✗ Branch 12 not taken.
24 switch(FFCore.quest_format[vZelda])
22059 {
22060 case 0x193:
22061 {
22062 zprint2("Last saved in version: 1.93, Beta %d\n", FFCore.quest_format[vBuild]); break;
22063 }
22064 case 0x192:
22065 {
22066 6 zprint2("Last saved in version: 1.92, Beta %d\n", FFCore.quest_format[vBuild]); break;
22067 }
22068 case 0x190:
22069 {
22070 12 zprint2("Last saved in version: 1.90");
22071
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 12 times.
12 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22072 12 else zprint2("\n");
22073 12 break;
22074 }
22075 case 0x188:
22076 {
22077 zprint2("Last saved in version: 1.88");
22078 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22079 else zprint2("\n");
22080 break;
22081 }
22082 case 0x187:
22083 {
22084 zprint2("Last saved in version: 1.87");
22085 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22086 else zprint2("\n");
22087 break;
22088 }
22089 case 0x186:
22090 {
22091 zprint2("Last saved in version: 1.86");
22092 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22093 else zprint2("\n");
22094 break;
22095 }
22096 case 0x185:
22097 {
22098 zprint2("Last saved in version: 1.85");
22099 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22100 else zprint2("\n");
22101 break;
22102 }
22103 case 0x184:
22104 {
22105 6 zprint2("Last saved in version: 1.84");
22106
1/2
✗ Branch 0 not taken.
✓ Branch 1 taken 6 times.
6 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22107 6 else zprint2("\n");
22108 6 break;
22109 }
22110 case 0x183:
22111 {
22112 zprint2("Last saved in version: 1.83");
22113 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22114 else zprint2("\n");
22115 break;
22116 }
22117 case 0x182:
22118 {
22119 zprint2("Last saved in version: 1.82");
22120 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22121 else zprint2("\n");
22122 break;
22123 }
22124 case 0x181:
22125 {
22126 zprint2("Last saved in version: 1.81");
22127 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22128 else zprint2("\n");
22129 break;
22130 }
22131 case 0x180:
22132 {
22133 zprint2("Last saved in version: 1.80");
22134 if ( FFCore.quest_format[vBuild] ) zprint2(", Beta/Build %d\n", FFCore.quest_format[vBuild]);
22135 else zprint2("\n");
22136 break;
22137 }
22138 default:
22139 {
22140 zprint2("Last saved in version: %x, Beta %d\n", FFCore.quest_format[vZelda],FFCore.quest_format[vBuild]); break;
22141 }
22142 }
22143 24 }
22144
22145
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 if(loading_tileset_flags & TILESET_CLEARMAPS)
22146 {
22147 TheMaps.clear();
22148 TheMaps.resize(MAPSCRS*1);
22149 map_count = 1;
22150 map_autolayers.clear();
22151 map_autolayers.resize(6*1);
22152 for(size_t i = 0; i < MAPSCRS; ++i)
22153 {
22154 TheMaps[i].zero_memory();
22155 }
22156 }
22157
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 if(loading_tileset_flags & TILESET_CLEARHEADER)
22158 {
22159 memset(Header->password, 0, sizeof(Header->password));
22160 memset(Header->minver, 0, sizeof(Header->minver));
22161 memset(Header->title, 0, sizeof(Header->title));
22162 memset(Header->author, 0, sizeof(Header->author));
22163 memset(Header->version, 0, sizeof(Header->version));
22164 Header->use_keyfile = 0;
22165 Header->dirty_password = false;
22166 cvs_MD5Context ctx;
22167 cvs_MD5Init(&ctx);
22168 cvs_MD5Update(&ctx, (const uint8_t*)"", 0);
22169 cvs_MD5Final(Header->pwd_hash, &ctx);
22170 }
22171
22172 695 return qe_OK;
22173
22174 invalid:
22175 // TODO: It's too easy to forget to jump to this label, and accidentally leave the file open.
22176 // Should wrap PACKFILE in a std::unique_pointer with a custom deallocator.
22177 box_out("error.");
22178 box_eol();
22179 box_end(true);
22180
22181 pack_fclose(f);
22182
22183 if(!oldquest)
22184 {
22185 if(exists(tmpfilename))
22186 {
22187 delete_file(tmpfilename);
22188 }
22189 }
22190
22191 return qe_invalid;
22192
22193 695 }
22194
22195 static bool _is_loading_quest;
22196
22197 bool is_loading_quest()
22198 {
22199 return _is_loading_quest;
22200 }
22201
22202 695 int32_t loadquest(const char *filename, zquestheader *Header, miscQdata *Misc,
22203 zctune *tunes, bool show_progress, byte *skip_flags, byte printmetadata,
22204 bool report, byte qst_num, dword tilesetflags)
22205 {
22206 695 loading_tileset_flags = tilesetflags;
22207 695 const char* basename = get_filename(filename);
22208 695 zapp_reporting_add_breadcrumb("load_quest", basename);
22209 695 zapp_reporting_set_tag("qst.filename", basename);
22210
22211 695 loading_qst_name = filename;
22212 695 loading_qst_num = qst_num;
22213 // In CI, builds are cached for replay tests, which can result in their build dates being earlier than what it would be locally.
22214 // So to avoid a more-recently updated .qst file from hitting the "last saved in a newer version" prompt, we disable in CI.
22215
1/2
✓ Branch 0 taken 695 times.
✗ Branch 1 not taken.
695 if (!is_ci())
22216 loadquest_report = report;
22217
22218 695 _is_loading_quest = true;
22219 695 auto start = std::chrono::steady_clock::now();
22220 695 int32_t ret = _lq_int(filename, Header, Misc, tunes, show_progress, skip_flags, printmetadata);
22221 695 int32_t load_ms = std::chrono::duration_cast<std::chrono::milliseconds>(std::chrono::steady_clock::now() - start).count();
22222 695 zprint2("Time to load qst: %d ms\n", load_ms);
22223 695 _is_loading_quest = false;
22224
22225
2/2
✓ Branch 0 taken 694 times.
✓ Branch 1 taken 1 times.
695 if(show_progress)
22226 {
22227
1/2
✓ Branch 0 taken 1 times.
✗ Branch 1 not taken.
1 if(ret)
22228 {
22229 box_out("-- Error loading quest file! --");
22230 box_end(true);
22231 }
22232 1 else box_end(false);
22233 1 }
22234
22235 695 load_tmp_zi = NULL;
22236 695 loading_qst_name = NULL;
22237 695 loadquest_report = false;
22238 695 loading_qst_num = 0;
22239
22240 695 zapp_reporting_set_tag("qst.author", Header->author);
22241 695 zapp_reporting_set_tag("qst.title", Header->title);
22242 695 zapp_reporting_set_tag("qst.zc_version", Header->getVerStr());
22243
22244 695 return ret;
22245 }
22246